Part Number Hot Search : 
RF9130 BU2727DX 1SMA4755 DB104 DM74A RF9130 CDT100 C2012X7R
Product Description
Full Text Search
 

To Download MC68HC908QC1612 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  mc68hc908qc16 data shee t, addendum 5/2012 freescale semiconductor 1 addendum to mc68hc908qc16, rev. 5 this addendum introduces a change to this data sheet. chapter 18 development support, section 18.3.2 security a security feature discourages unauthorized reading of flash locations while in monitor mode. the host can bypass the security feature at monitor mode entry by sending eight security bytes that match the bytes at locations $fff6?$fffd. locations $fff6?$fffd contain user-defined data. note do not leave locations $fff6?$fffd bl ank. for security reasons, program locations $fff6?$fffd even if they are not used for vectors. changes to: chapter 18 development support, section 18.3.2 security a security feature discourages unauthorized reading of flash locations while in monitor mode. the host can bypass the security feature at monitor mode entry by sending eight security bytes that match the bytes at locations $fff6?$fffd. locations $fff6?$fffd contain user-defined data. note do not leave locations $fff6?$fffd bl ank. for security reasons, program locations $fff6?$fffd even if they ar e not used for vectors. an improved security function denies monitor mode entry if five or more of the eight security bytes are $00 (zero bytes).
m68hc08 microcontrollers freescale.com mc68hc908qc16 mc68hc908qc8 mc68hc908qc4 data sheet mc68hc908qc16 rev. 5 4/2008

mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 3 freescale and the freescale logo are trademarks of freescale semiconductor, inc. this product incorporates superflash?technology licensed from sst. freescale semiconductor, inc., 2007, 2008. all rights reserved. mc68hc908qc16 mc68hc908qc8 mc68hc908qc4 data sheet to provide the most up-to-date information, the revision of our documents on the world wide web will be the most current. your printed copy may be an earlier revision. to verify you have the latest information available, refer to: http://www.freescale.com
revision history mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 4 freescale semiconductor the following revision history table summarizes changes contained in this document. for your convenience, the page number designators have been linked to the appropriate location. revision history date revision level description page number(s) april, 2006 1.0 initial release n/a may, 2006 1.1 19.5 5-v dc electrical characteristics ?updated values 237 19.8 3.3-v dc electrical characteristics ?updated values 240 19.11 oscillator characteristics ?updated values 243 figure 19-9. typical 5-volt run current versus bus frequency (25 c) and figure 19-10. typical 3.3-volt run current versus bus frequency (25 c) added 247 october, 2006 2.0 1.7 unused pin termination ?added new section 24 11.2 unused pin termination ?replaced note with new section 107 19.5 5-v dc electrical characteristics ?new values for: dc injection current low-voltage inhibit reset, trip rising voltage 237 19.8 3.3-v dc electrical characteristics ?new values for: dc injection current low-voltage inhibit reset, trip rising voltage 240 19.12 supply current characteristics ?new values for stop mode supply currents at ?0 to 125c 246 20.3 package dimensions ?updated package dimension drawing for the 28-lead tssop. 261 april, 2007 3.0 table 1-2. pin functions ?added note 22 figure 2-2. control, status, and data registers ?corrected port c data register bit ptc3 27 chapter 3 analog-to-digital converter (adc10) module ?renamed adcsc register to adscr to be consistent with development tools 45 chapter 4 configuration registers (config1 and config2) ?changed cgmxclk to busclkx4 60 11.3 port a ?added information to first paragraph of note 107 11.3.1 port a data register ?corrected bit designations for the first entry under figure 11-1. port a data register (pta). 108 11.5 port c ?added note and corrected address location designation in last paragraph 112 113 chapter 13 enhanced serial communications interface (esci) module changed scibdsrc to escibdsrc and cgmxclk to busclkx4 123 13.9.3 bit time measurement ?corrected first sentence of listing number 1 150 figure 18-18. monitor mode entry timing ?changed cgmxclk to busclkx4 234 october, 2007 4.0 in 19.12 supply current characteristics, updated stop i dd values 246 april, 2008 5.0 in 19.12 supply current characteristics , reverted to rev. 3 stop i dd values 246
mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 5 list of sections chapter 1 general description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17 chapter 2 memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25 chapter 3 analog-to-digital converter (adc10) module . . . . . . . . . . . . . . . . . . . . . . . . . . .45 chapter 4 configuration registers (config1 and config2) . . . . . . . . . . . . . . . . . . . . . .59 chapter 5 computer operating properly (cop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .63 chapter 6 central processor unit (cpu). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .67 chapter 7 external interrupt (irq) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .79 chapter 8 keyboard interrupt module (kbi) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .85 chapter 9 low-voltage inhibit (lvi). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .93 chapter 10 oscillator mode (osc). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .97 chapter 11 input/output ports (ports) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .107 chapter 12 periodic wakeup module (pwu) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .117 chapter 13 enhanced serial communications interface (esci) module . . . . . . . . . . . . .123 chapter 14 system integration module (sim) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .153 chapter 15 serial peripheral interface (spi) module . . . . . . . . . . . . . . . . . . . . . . . . . . . . .169 chapter 16 timer interface module (tim1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .189 chapter 17 timer interface module (tim2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .205 chapter 18 development support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .219 chapter 19 electrical specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .235 chapter 20 ordering information and mechanical specifications . . . . . . . . . . . . . . . . . .257
list of sections mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 6 freescale semiconductor
mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 7 table of contents chapter 1 general description 1.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 1.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 1.3 mcu block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 1.4 pin assignments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 1.5 pin functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 1.6 pin function priority . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 1.7 unused pin termination . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 chapter 2 memory 2.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 2.2 unimplemented memory locations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 2.3 reserved memory locations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25 2.4 direct page registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 2.5 random-access memory (ram) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 2.6 flash memory (flash) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .36 2.6.1 flash control register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 2.6.2 flash page erase operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 2.6.3 flash mass erase operation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 2.6.4 flash program operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 2.6.5 flash protection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 2.6.6 flash block protect register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 2.6.7 eeprom memory emulation using flash memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 chapter 3 analog-to-digital converter (adc10) module 3.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 3.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 3.3 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 3.3.1 clock select and divide circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .47 3.3.2 input select and pin control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .48 3.3.3 conversion control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 3.3.3.1 initiating conversions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 3.3.3.2 completing conversions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 3.3.3.3 aborting conversions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 3.3.3.4 total conversion time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .49 3.3.4 sources of error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 3.3.4.1 sampling error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 3.3.4.2 pin leakage error. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 3.3.4.3 noise-induced errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
table of contents mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 8 freescale semiconductor 3.3.4.4 code width and quantization error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 3.3.4.5 linearity errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 3.3.4.6 code jitter, non-monotonicity and missing codes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 3.4 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 3.5 low-power modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 3.5.1 wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 3.5.2 stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 3.6 adc10 during break interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .52 3.7 i/o signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 3.7.1 adc10 analog power pin (v dda ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 3.7.2 adc10 analog ground pin (v ssa ). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 3.7.3 adc10 voltage reference high pin (v refh ). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 3.7.4 adc10 voltage reference low pin (v refl ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 3.7.5 adc10 channel pins (adn). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 3.8 registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 3.8.1 adc10 status and control register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 3.8.2 adc10 result high register (adrh) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 3.8.3 adc10 result low register (adrl) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 3.8.4 adc10 clock register (adclk) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 chapter 4 configuration registers (config1 and config2) 4.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 4.2 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 chapter 5 computer operating properly (cop) 5.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 5.2 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 5.3 i/o signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 5.3.1 busclkx4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 5.3.2 stop instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 5.3.3 copctl write . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 5.3.4 power-on reset. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 5.3.5 internal reset. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 5.3.6 copd (cop disable). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 5.3.7 coprs (cop rate select) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 5.4 cop control register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 5.5 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 5.6 monitor mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 5.7 low-power modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 5.7.1 wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 5.7.2 stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 5.8 cop module during break mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 9 chapter 6 central processor unit (cpu) 6.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 6.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 6.3 cpu registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 6.3.1 accumulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 6.3.2 index register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 6.3.3 stack pointer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 6.3.4 program counter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 6.3.5 condition code register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 6.4 arithmetic/logic unit (alu) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 6.5 low-power modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 6.5.1 wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 6.5.2 stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 6.6 cpu during break interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 6.7 instruction set summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 6.8 opcode map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 chapter 7 external interrupt (irq) 7.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 7.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 7.3 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 7.3.1 mode = 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 7.3.2 mode = 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 7.4 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 7.5 low-power modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 7.5.1 wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 7.5.2 stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 7.6 irq module during break interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 7.7 i/o signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 7.7.1 irq input pins ( irq) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 7.8 registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 chapter 8 keyboard interrupt module (kbi) 8.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 8.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 8.3 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 8.3.1 keyboard operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 8.3.1.1 modek = 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 8.3.1.2 modek = 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 8.3.2 keyboard initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 8.4 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 8.5 low-power modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 8.5.1 wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 8.5.2 stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 8.6 kbi during break interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
table of contents mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 10 freescale semiconductor 8.7 i/o signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 8.7.1 kbi input pins (kbi7:kbi0) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .89 8.8 registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 8.8.1 keyboard status and control register (kbscr). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 8.8.2 keyboard interrupt enable register (kbier). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 8.8.3 keyboard interrupt polarity register (kbipr) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 chapter 9 low-voltage inhibit (lvi) 9.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 9.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 9.3 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 9.3.1 polled lvi operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 9.3.2 forced reset operation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 9.3.3 lvi hysteresis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 9.3.4 lvi trip selection. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 9.4 lvi interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 9.5 low-power modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 9.5.1 wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 9.5.2 stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 9.6 registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 chapter 10 oscillator mode (osc) 10.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 10.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 10.3 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 10.3.1 internal signal definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 10.3.1.1 oscillator enable signal (simoscen) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 10.3.1.2 xtal oscillator clock (xtalclk) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 10.3.1.3 rc oscillator clock (rcclk) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 10.3.1.4 internal oscillator clock (intclk) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 10.3.1.5 bus clock times 4 (busclkx4) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 10.3.1.6 bus clock times 2 (busclkx2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 10.3.2 internal oscillator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 10.3.2.1 internal oscillator trimming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 10.3.2.2 internal to external clock switching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 10.3.2.3 external to internal clock switching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 10.3.3 external oscillator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 10.3.4 xtal oscillator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 10.3.5 rc oscillator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 10.4 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 10.5 low-power modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 10.5.1 wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 10.5.2 stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 10.6 osc during break interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 10.7 i/o signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 10.7.1 oscillator input pin (osc1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 10.7.2 oscillator output pin (osc2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 11 10.8 registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 10.8.1 oscillator status and control register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 10.8.2 oscillator trim register (osctrim) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 chapter 11 input/output ports (ports) 11.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 11.2 unused pin termination . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 11.3 port a . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 11.3.1 port a data register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 11.3.2 data direction register a. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 11.3.3 port a input pullup enable register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 11.4 port b . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 11.4.1 port b data register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 11.4.2 data direction register b. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 11.4.3 port b input pullup enable register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 11.5 port c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 11.5.1 port c data register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 11.5.2 data direction register c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 11.5.3 port c input pullup enable register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 11.6 port d . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 11.6.1 port d data register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 11.6.2 data direction register d . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 11.6.3 port d input pullup enable register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 chapter 12 periodic wakeup module (pwu) 12.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 12.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 12.3 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 12.4 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 12.5 low-power modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 12.5.1 wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 12.5.2 stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 12.6 pwu during break interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 12.7 i/o signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 12.8 registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 12.8.1 periodic wakeup status and control register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 12.8.2 periodic wakeup prescaler register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 12.8.3 periodic wakeup modulo register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 chapter 13 enhanced serial communications interface (esci) module 13.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 13.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 13.3 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 13.3.1 data format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 13.3.2 transmitter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 13.3.2.1 character length . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
table of contents mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 12 freescale semiconductor 13.3.2.2 character transmission . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 13.3.2.3 break characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 13.3.2.4 idle characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 13.3.2.5 inversion of transmitted output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 13.3.3 receiver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 13.3.3.1 character length . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 13.3.3.2 character reception. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 13.3.3.3 data sampling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130 13.3.3.4 framing errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 13.3.3.5 baud rate tolerance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 13.3.3.6 receiver wakeup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 13.4 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134 13.4.1 transmitter interrupts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134 13.4.2 receiver interrupts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134 13.4.3 error interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134 13.5 low-power modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 13.5.1 wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 13.5.2 stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 13.6 esci during break interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 13.7 i/o signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 13.7.1 esci transmit data (txd) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 13.7.2 esci receive data (rxd) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136 13.8 registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136 13.8.1 esci control register 1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136 13.8.2 esci control register 2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 13.8.3 esci control register 3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 13.8.4 esci status register 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141 13.8.5 esci status register 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 13.8.6 esci data register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 13.8.7 esci baud rate register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 13.8.8 esci prescaler register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 13.9 esci arbiter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 13.9.1 esci arbiter control register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 13.9.2 esci arbiter data register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 13.9.3 bit time measurement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 13.9.4 arbitration mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 chapter 14 system integration module (sim) 14.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 14.2 rst and irq pins initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 14.3 sim bus clock control and generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 14.3.1 bus timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 14.3.2 clock start-up from por. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 14.3.3 clocks in stop mode and wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 14.4 reset and system initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 14.4.1 external pin reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 13 14.4.2 active resets from internal sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156 14.4.2.1 power-on reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 14.4.2.2 computer operating properly (cop) reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 14.4.2.3 illegal opcode reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158 14.4.2.4 illegal address reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158 14.4.2.5 low-voltage inhibit (lvi) reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158 14.5 sim counter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158 14.5.1 sim counter during power-on reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158 14.5.2 sim counter during stop mode recovery. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158 14.5.3 sim counter and reset states . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 14.6 exception control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 14.6.1 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 14.6.1.1 hardware interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 14.6.1.2 swi instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 14.6.2 interrupt status registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 14.6.2.1 interrupt status register 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 14.6.2.2 interrupt status register 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 14.6.2.3 interrupt status register 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 14.6.3 reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 14.6.4 break interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 14.6.5 status flag protection in break mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 14.7 low-power modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 14.7.1 wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 14.7.2 stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 14.8 sim registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166 14.8.1 sim reset status register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 14.8.2 break flag control register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168 chapter 15 serial peripheral interface (spi) module 15.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 15.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 15.3 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 15.3.1 master mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172 15.3.2 slave mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172 15.3.3 transmission formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 15.3.3.1 clock phase and polarity controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 15.3.3.2 transmission format when cpha = 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 15.3.3.3 transmission format when cpha = 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174 15.3.3.4 transmission initiation latency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 15.3.4 queuing transmission data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 15.3.5 resetting the spi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 15.3.6 error conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 15.3.6.1 overflow error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 15.3.6.2 mode fault error. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 15.4 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 15.5 low-power modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182 15.5.1 wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182 15.5.2 stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
table of contents mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 14 freescale semiconductor 15.6 spi during break interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182 15.7 i/o signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183 15.7.1 miso (master in/slave out). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183 15.7.2 mosi (master out/slave in). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183 15.7.3 spsck (serial clock) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183 15.7.4 ss (slave select) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183 15.8 registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 15.8.1 spi control register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 15.8.2 spi status and control register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186 15.8.3 spi data register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188 chapter 16 timer interface module (tim1) 16.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189 16.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189 16.3 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189 16.3.1 tim1 counter prescaler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192 16.3.2 input capture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192 16.3.3 output compare. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192 16.3.3.1 unbuffered output compare . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192 16.3.3.2 buffered output compare . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192 16.3.4 pulse width modulation (pwm) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193 16.3.4.1 unbuffered pwm signal generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194 16.3.4.2 buffered pwm signal generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194 16.3.4.3 pwm initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195 16.4 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196 16.5 low-power modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196 16.5.1 wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196 16.5.2 stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196 16.6 tim1 during break interrupts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 16.7 i/o signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 16.7.1 tim1 channel i/o pins (t1ch3:t1ch0) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 16.7.2 tim1 clock pin (t1clk) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 16.8 registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 16.8.1 tim1 status and control register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 16.8.2 tim1 counter registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 16.8.3 tim1 counter modulo registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200 16.8.4 tim1 channel status and control registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200 16.8.5 tim1 channel registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204 chapter 17 timer interface module (tim2) 17.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205 17.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205 17.3 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205 17.3.1 tim2 counter prescaler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205 17.3.2 input capture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 15 17.3.3 output compare. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207 17.3.3.1 unbuffered output compare . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207 17.3.3.2 buffered output compare . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 17.3.4 pulse width modulation (pwm) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 17.3.4.1 unbuffered pwm signal generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209 17.3.4.2 buffered pwm signal generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210 17.3.4.3 pwm initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210 17.4 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 17.5 low-power modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 17.5.1 wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 17.5.2 stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 17.6 tim2 during break interrupts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 17.7 i/o signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212 17.7.1 tim2 channel i/o pins (t2ch1:t2ch0) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212 17.7.2 tim2 clock pin (t2clk) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212 17.8 registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212 17.8.1 tim2 status and control register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212 17.8.2 tim2 counter registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214 17.8.3 tim2 counter modulo registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215 17.8.4 tim2 channel status and control registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215 17.8.5 tim2 channel registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218 chapter 18 development support 18.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219 18.2 break module (brk) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219 18.2.1 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219 18.2.1.1 flag protection during break interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221 18.2.1.2 tim1 during break interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221 18.2.1.3 cop during break interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221 18.2.2 break module registers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222 18.2.2.1 break status and control register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222 18.2.2.2 break address registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222 18.2.2.3 break auxiliary register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223 18.2.2.4 break status register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223 18.2.2.5 break flag control register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223 18.2.3 low-power modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224 18.3 monitor module (mon) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224 18.3.1 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224 18.3.1.1 normal monitor mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228 18.3.1.2 forced monitor mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229 18.3.1.3 monitor vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229 18.3.1.4 data format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230 18.3.1.5 break signal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230 18.3.1.6 baud rate. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230 18.3.1.7 commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230 18.3.2 security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
table of contents mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 16 freescale semiconductor chapter 19 electrical specifications 19.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235 19.2 absolute maximum ratings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235 19.3 functional operating range . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236 19.4 thermal characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236 19.5 5-v dc electrical characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237 19.6 typical 5-v output drive characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239 19.7 5-v control timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240 19.8 3.3-v dc electrical characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240 19.9 typical 3.3-v output drive characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242 19.10 3.3-v control timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243 19.11 oscillator characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243 19.12 supply current characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246 19.13 adc10 characteristics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248 19.14 5.0-volt spi characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250 19.15 3.3-volt spi characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251 19.16 timer interface module characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254 19.17 memory characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255 chapter 20 ordering information and mechanical specifications 20.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257 20.2 mc order numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257 20.3 package dimensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 17 chapter 1 general description 1.1 introduction the mc68hc908qc16, mc68hc908qc8, and mc68hc908qc4 are members of the low-cost, high-performance m68hc08 family of 8-bit microcontroller units (mcus). all mcus in the family use the enhanced m68hc08 central processor unit (cpu08) and are available with a variety of modules, memory sizes and types, and package types. 0.4 1.2 features features include: high-performance m68hc08 cpu core fully upward-compatible object code with m68hc05 family 5.0-v and 3.3-v operating voltages (v dd ) 8-mhz internal bus operation at 5 v, 4-mhz at 3.3 v trimmable internal oscillator software selectable 1 mhz, 2 mhz, 3.2 mhz, or 6.4 mhz internal bus operation 8-bit trim capability 25% untrimmed trimmable to approximately 0.4% (1) software selectable crystal oscillator range, 32?00 khz, 1? mhz, and 8?2 mhz software configurable input clock from either internal or external source auto wakeup from stop capability using dedicated internal 32-khz rc or bus clock source flash security (2) on-chip in-application programmable flash memory (with internal program/erase voltage generation) table 1-1. summary of device variations device flash memory size ram pin count mc68hc908qc16 16 kbytes 512 bytes 16, 20, 28 pins mc68hc908qc8 8 kbytes 384 bytes 16, 20, 28 pins mc68hc908qc4 4 kbytes 384 bytes 16, 20, 28 pins 1. see 19.11 oscillator characteristics for internal oscillator specifications 2. no security feature is absolutely secure. however, freescale? strategy is to make reading or copying the flash difficult for unauthorized users.
general description mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 18 freescale semiconductor enhanced serial communications interface (esci) module serial peripheral interface (spi) module 4-channel, 16-bit timer interface (tim1) module 2-channel, 16-bit timer interface (tim2) module 10-channel, 10-bit analog-to-digital converter (adc) with internal bandgap reference channel (adc10) up to 24 bidirectional input/output (i/o) lines and two input only: six shared with keyboard interrupt function ten shared with adc four shared with tim1 two shared with tim2 two shared with esci four shared with spi one input only shared with external interrupt (irq) high current sink/source capability on all port pins selectable pullups on all ports, selectable on an individual bit basis three-state ability on all port pins 6-bit keyboard interrupt with wakeup feature (kbi) programmable for rising/falling edge or high/low level detection low-voltage inhibit (lvi) module features: software selectable trip point in config register system protection features: computer operating properly (cop) watchdog low-voltage detection with reset illegal opcode detection with reset illegal address detection with reset external asynchronous interrupt pin with internal pullup ( irq) shared with general-purpose input pin master asynchronous reset pin with internal pullup ( rst) shared with general-purpose input/output (i/o) pin memory mapped i/o registers power saving stop and wait modes mc68hc908qc16, mc68hc908qc8, and mc68hc908qc4 are available in these packages: 28-pin small outline integrated circuit package (soic) 28-pin thin shrink small outline package (tssop) 20-pin soic 20-pin tssop 16-pin soic 16-pin tssop
mcu block diagram mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 19 features of the cpu08 include the following: enhanced hc05 programming model extensive loop control functions 16 addressing modes (eight more than the hc05) 16-bit index register and stack pointer memory-to-memory data transfers fast 8 8 multiply instruction fast 16/8 divide instruction binary-coded decimal (bcd) instructions optimization for controller applications efficient c language support 1.3 mcu block diagram figure 1-1 shows the structure of the mc68hc908qc16, mc68hc908qc8, and mc68hc908qc4. 1.4 pin assignments the mc68hc908qc16, mc68hc908qc8, and mc68hc908qc4 are available in 16-pin, 20-pin, and 28-pin packages. figure 1-2 shows the pin assignment for these packages. 1.5 pin functions table 1-2 provides a description of the pin functions.
general description mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 20 freescale semiconductor figure 1-1. block diagram all port pins can be configured with internal pullup ptc not available on 16-pin devices (see note in 11.1 introduction) ptd not available on 16-pin or 20-pin devices (see note in 11.1 introduction) pta0/t1ch0/ad0/kbi0 pta1/t1ch1/ad1/kbi1 pta2/ irq/kbi2/t1clk pta3/ rst/kbi3 pta4/osc2/ad2/kbi4 pta5/osc1/ad3/kbi5 4-channel 16-bit timer module keyboard interrupt module single interrupt module periodic wakeup low-voltage inhibit cop module 10-channel 10-bit adc enhanced serial ptb0/spsck/ad4 ptb ddrb m68hc08 cpu pta ddra ptb1/mosi/t2ch1/ad5 ptb2/miso/t2ch0/ad6 ptb3/ ss/t2clk/ad7 ptb4/rxd/t2ch0/ad8 ptb5/txd/t2ch1/ad9 ptb6/t1ch2 ptb7/t1ch3 power supply v dd v ss clock generator communications interface module module serial peripheral interface 16,384 bytes mc68hc908qc16 8192 bytes mc68hc908qc8 512 bytes mc68hc908qc16 384 bytes mc68hc908qc8 break module monitor rom 2-channel 16-bit timer module ptc0 ptc1 ptc2 ptc3 ptc ddrc ptd0 ptd ddrd ptd1 ptd2 ptd3 ptd4 ptd5 ptd6 ptd7 mc68hc908qc4 user ram user flash 4096 bytes 384 bytes mc68hc908qc4
pin functions mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 21 figure 1-2. mc68hc908qc16, mc68hc908qc8, and mc68hc908qc4 pin assignments 1 2 3 4 5 6 7 8 16-pin assignment mc68hc908qcxx soic 16 15 14 13 12 11 10 9 1 2 3 4 5 6 7 8 20-pin assignment mc68hc908qcxx soic 20 19 18 17 16 15 14 13 9 10 12 11 v dd ptb7/t1ch3 ptb6/t1ch2 pta5/osc1/ad3/kbi5 pta4/osc2/ad2/kbi4 ptb5/txd/t2ch1/ad9 ptb4/rxd/t2ch0/ad8 pta3/ rst/kbi3 pta2/ irq/kbi2/t1clk ptb3/ ss/t2clk/ad7 ptb2/miso/t2ch0/ad6 pta1/t1ch1/ad1/kbi1 pta0/t1ch0/ad0/kbi0 ptb1/mosi/t2ch1/ad5 ptb0/spsck/ad4 v ss v dd ptb7/t1ch3 ptb6/t1ch2 pta5/osc1/ad3/kbi5 pta4/osc2/ad2/kbi4 ptc1 ptc0 ptb5/txd/t2ch1/ad9 ptb4/rxd/t2ch0/ad8 pta3/ rst/kbi3 ptb2/miso/t2ch0/ad6 pta1/t1ch1/ad1/kbi1 ptc3 ptc2 pta0/t1ch0/ad0/kbi0 ptb1/mosi/t2ch1/ad5 ptb0/spsck/ad4 v ss pta2/ irq/kbi2/t1clk ptb3/ ss/t2clk/ad7 16-pin assignment mc68hc908qcxx tssop pta0/t1ch0/ad0/kbi0 ptb1/mosi/t2ch1/ad5 ptb0/spsck/ad4 v ss v dd ptb7/t1ch3 ptb6/t1ch2 pta5/osc1/ad3/kbi5 pta1/t1ch1/ad1/kbi1 ptb2/miso/t2ch0/ad6 ptb3/ ss/t2clk/ad7 pta2/ irq/kbi2/t1clk pta3/ rst/kbi3 ptb4/rxd/t2ch0/ad8 ptb5/txd/t2ch1/ad9 pta4/osc2/ad2/kbi4 ptc2 pta0/t1ch0/ad0/kbi0 ptb1/mosi/t2ch1/ad5 ptb0/spsck/ad4 v ss v dd ptb7/t1ch3 ptb6/t1ch2 ptb5/txd/t2ch1/ad9 ptb4/rxd/t2ch0/ad8 pta3/ rst/kbi3 pta2/ irq/kbi2/t1clk ptb3/ ss/t2clk/ad7 ptb2/miso/t2ch0/ad6 pta1/t1ch1/ad1/kbi1 ptc3 pta5/osc1/ad3/kbi5 pta4/osc2/ad2/kbi4 ptc1 ptc0 1 2 3 4 5 6 7 8 16 15 14 13 12 11 10 9 20-pin assignment mc68hc908qcxx tssop 1 2 3 4 5 6 7 8 20 19 18 17 16 15 14 13 9 10 12 11 ptd5 ptd4 ptc2 pta0/t1ch0/ad0/kbi0 ptb1/mosi/t2ch1/ad5 ptb0/spsck/ad4 v ss v dd pta3/ rst/kbi3 pta2/ irq/kbi2/t1clk ptb3/ ss/t2clk/ad7 ptb2/miso/t2ch0/ad6 pta1/t1ch1/ad1/kbi1 ptc3 ptd7 ptd6 ptb7/t1ch3 ptb6/t1ch2 ptb5/txd/t2ch1/ad9 ptb4/rxd/t2ch0/ad8 28-pin assignment mc68hc908qcxx tssop 1 2 3 4 5 6 7 8 28 27 26 25 24 23 22 21 9 10 20 19 11 12 18 17 13 14 16 15 ptd0 ptc0 ptd2 ptd1 pta5/osc1/ad3/kbi5 pta4/osc2/ad2/kbi4 ptc1 ptd3 1 2 3 4 5 6 7 8 28-pin assignment mc68hc908qcxx soic 28 27 26 25 24 23 22 21 9 10 20 19 11 12 18 17 13 14 16 15 ptd6 ptd5 ptd4 ptc2 pta0/t1ch0/ad0/kbi0 ptb1/mosi/t2ch1/ad5 ptb0/spsck/ad4 v ss ptc3 ptd7 v dd ptb7/t1ch3 ptb6/t1ch2 pta5/osc1/ad3/kbi5 pta4/osc2/ad2/kbi4 ptc1 ptd3 ptd2 ptd1 ptd0 ptb2/miso/t2ch0/ad6 pta1/t1ch1/ad1/kbi1 pta2/ irq/kbi2/t1clk ptb3/ ss/t2clk/ad7 ptc0 ptb5/txd/t2ch1/ad9 ptb4/rxd/t2ch0/ad8 pta3/ rst/kbi3 note: t2ch0 and t2ch1 can be repositioned using tim2pos in config2.
general description mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 22 freescale semiconductor table 1-2. pin functions pin name description input/outpu t v dd power supply power v ss power supply ground power pta0 pta0 ?general purpose i/o port input/output t1ch0 ?timer channel 0 i/o input/output ad0 ?a/d channel 0 input input kbi0 ?keyboard interrupt input 0 input pta1 pta1 ?general purpose i/o port input/output t1ch1 ?timer channel 1 i/o input/output ad1 ?a/d channel 1 input input kbi1 ?keyboard interrupt input 1 input pta2 (1) pta2 ?general purpose input-only port input irq ?external interrupt with programmable pullup and schmitt trigger input input kbi2 ?keyboard interrupt input 2 input t1clk ?tim1 timer clock input input pta3 pta3 ?general purpose i/o port input/output rst ?reset input, active low with internal pullup and schmitt trigger input kbi3 ?keyboard interrupt input 3 input pta4 pta4 ?general purpose i/o port input/output osc2 ?tal oscillator output (xtal option only) rc or internal oscillator output (osc2en = 1 in ptapue register) output output ad2 ?a/d channel 2 input input kbi4 ?keyboard interrupt input 4 input pta5 pta5 ?general purpose i/o port input/output osc1 xtal, rc, or external oscillator input input ad3 ?a/d channel 3 input input kbi5 ?keyboard interrupt input 5 input ptb0 ptb0 ?general-purpose i/o port input/output spsck?spi serial clock input/output ad4 ?a/d channel 4 input input ptb1 ptb1 ?general-purpose i/o port input/output mosi ?spi data transmitted input/output t2ch1 (2) ?tim2 channel 1 input/output ad5 ?a/d channel 5 input input ?continued on next page
pin functions mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 23 ptb2 ptb2 ?general-purpose i/o port input/output miso ?spi data received input/output t2ch0 (2) ?tim2 channel 0 input/output ad6 ?a/d channel 6 input input ptb3 ptb3 ?general-purpose i/o port input/output ss ?spi slave select input t2clk ?tim2 timer clock input input ad7 ?a/d channel 7 input input ptb4 ptb4 ?general-purpose i/o port input/output rxd ?esci receive data i/o input t2ch0 (2) ?tim2 channel 0 input/output ad8 ?a/d channel 8 input input ptb5 ptb5 ?general-purpose i/o port input/output txd ?esci transport data i/o output t2ch1 (2) ?tim2 channel 1 input/output ad9 ?a/d channel 9 input input ptb6 ptb6 ?general-purpose i/o port input/output t1ch2 ?timer channel 2 i/o input/output ptb7 ptb7 ?general-purpose i/o port input/output t1ch3 ?timer channel 3 i/o input/output ptc0?tc2 (3) general-purpose i/o port input/output ptc3 (1, 3) general-purpose input port input ptd0?td7 (4) general-purpose i/o port input/output 1. pta2 and ptc3 pins have high voltage detectors to enter special modes. 2. t2ch0 and t2ch1 can be repositioned using tim2pos in config2. 3. pins not available on 16-pin devices (see note in 11.1 introduction ). 4. pins not available on 16-pin or 20-pin devices (see note in 11.1 introduction). table 1-2. pin functions (continued) pin name description input/outpu t
general description mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 24 freescale semiconductor 1.6 pin function priority table 1-3 is meant to resolve the priority if multiple functions are enabled on a single pin. note upon reset all pins come up as input ports regardless of the priority table. 1.7 unused pin termination input pins and i/o port pins that are not used in the application must be terminated. this prevents excess current caused by floating inputs, and enhances immunity during noise or transient events. termination methods include: 1. configuring unused pins as outputs and driving high or low; 2. configuring unused pins as inputs and enabling internal pull-ups; 3. configuring unused pins as inputs and using external pull-up or pull-down resistors. never connect unused pins directly to v dd or v ss . since some general-purpose i/o pins are not available on all packages, these pins must be terminated as well. either method 1 or 2 above are appropriate. table 1-3. function priority in shared pins pin name highest-to-lowest priority sequence pta0 (1) 1. when a pin is to be used as an adc pin, the i/o port function should be left as an input and all other shared modules should be disabled. the adc does not override additional modules using the pin. ad0  t1ch0  kbi0  pta0 pta1 (1) ad1  t1ch1  kbi1  pta1 pta2 irq  t1clk  kbi2  pta2 pta3 rst  kbi3  pta3 pta4 (1) osc2  ad2  kbi4  pta4 pta5 (1) osc1  ad3  kbi5  pta5 ptb0 (1) ad4  spsck  ptb0 ptb1 (1) ad5  mosi  t2ch1 (2)  ptb1 2. t2ch0 and t2ch1 can be repositioned using tim2pos in config2 (see figure 2-2. control, status, and data registers ). ptb2 (1) ad6  miso  t2ch0 (2)  ptb2 ptb3 (1) ad7  ss  t2clk  ptb3 ptb4 (1) ad8  rxd  t2ch0 (2)  ptb4 ptb5 (1) ad9  txd  t2ch1 (2)  ptb5 ptb6 t1ch2  ptb6 ptb7 t1ch3  ptb7 ptcx ptcx ptdx ptdx
mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 25 chapter 2 memory 2.1 introduction the central processor unit (cpu08) can address 64 kbytes of memory space. the memory map is shown in figure 2-1 . 2.2 unimplemented memory locations executing code from an unimplemented location will cause an illegal address reset. in figure 2-1 , unimplemented locations are shaded. 2.3 reserved memory locations accessing a reserved location can have unpredictable effects on mcu operation. in figure 2-1 , reserved locations are marked with the word reserved or with the letter r. 2.4 direct page registers figure 2-2 shows the memory mapped registers. registers with addresses between $0000 and $00ff are considered direct page registers and all instructions including those with direct page addressing modes can access them. registers between $0100 and $ffff require non-direct page addressing modes. see chapter 6 central processor unit (cpu) for more information on addressing modes.
memory mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 26 freescale semiconductor $0000 $003f direct page registers 64 bytes $0040 $023f ram 512 bytes ram 384 bytes $0040 $01bf ram 384 bytes $0040 $01bf $0240 $024f registers 16 bytes reserved 128 bytes $01c0 $023f reserved 128 bytes $01c0 $023f $0250 $27ff unimplemented 9648 bytes $2800 $2a1f auxiliary rom 544 bytes $2a20 $2f7d unimplemented 1374 bytes $2f7e $2fff auxiliary rom 130 bytes $3000 $bdff unimplemented 36,352 bytes $be00 $fdff flash memory 16,384 bytes reserved 8192 bytes $be00 $ddff reserved 12,288 bytes $be00 $edff flash memory 8192 bytes $de00 $fdff $fe00 $fe1f miscellaneous registers 32 bytes flash memory 4096 bytes $ee00 $fdff $fe20 $ff7d monitor rom 350 bytes $ff7e $ffaf unimplemented 50 bytes $ffb0 $ffbd flash 14 bytes $ffbe $ffc1 miscellaneous registers $ffc2 $ffcf flash 14 bytes $ffd0 $ffff user vectors 48 bytes mc68hc908qc16 memory map mc68hc908qc8 memory map mc68hc908qc4 memory map figure 2-1. memory map
direct page registers mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 27 addr. register name bit 7 6 5 4321bit 0 $0000 port a data register (pta) see page 108. read: 0 r pta5 pta4 pta3 pta2 pta1 pta0 write: 0 reset: unaffected by reset $0001 port b data register (ptb) see page 110. read: ptb7 ptb6 ptb5 ptb4 ptb3 ptb2 ptb1 ptb0 write: reset: unaffected by reset $0002 port c data register (ptc) see page 112. read: 0 0 0 0 ptc3 ptc2 ptc1 ptc0 write: reset: unaffected by reset $0003 port d data register (ptd) see page 114. read: ptd7 ptd6 ptd5 ptd4 ptd3 ptd2 ptd1 ptd0 write: reset: unaffected by reset $0004 data direction register a (ddra) see page 108. read: 0 0 ddra5 ddra4 ddra3 0 ddra1 ddra0 write: reset:00000000 $0005 data direction register b (ddrb) see page 110. read: ddrb7 ddrb6 ddrb5 ddrb4 ddrb3 ddrb2 ddrb1 ddrb0 write: reset:00000000 $0006 data direction register c (ddrc) see page 113. read: 0 0 0 0 0 ddrc2 ddrc1 ddrc0 write: reset:00000000 $0007 data direction register d (ddrd) see page 115. read: ddrd7 ddrd6 ddrd5 ddrd4 ddrd3 ddrd2 ddrd1 ddrd0 write: reset:00000000 $0008 reserved $0009 port c input pullup enable register (ptcpue) see page 114. read: 0 0 0 0 ptcpue3 ptcpue2 ptcpue1 ptcpue0 write: reset:00000000 $000a port d input pullup enable register (ptdpue) see page 116. read: ptdpue7 ptdpue6 ptdpue5 ptdpue4 ptdpue3 ptdpue2 ptdpue1 ptdpue0 write: reset:00000000 $000b port a input pullup enable register (ptapue) see page 109. read: osc2en 0 ptapue5 ptapue4 ptapue3 ptapue2 ptapue1 ptapue0 write: reset:00000000 $000c port b input pullup enable register (ptbpue) see page 111. read: ptbpue7 ptbpue6 ptbpue5 ptbpue4 ptbpue3 ptbpue2 ptbpue1 ptbpue0 write: reset:00000000 = unimplemented r = reserved u = unaffected figure 2-2. control, status, and data registers (sheet 1 of 8)
memory mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 28 freescale semiconductor $000d spi control register (spcr) see page 185. read: sprie r spmstr cpol cpha spwom spe sptie write: reset:00101000 $000e spi status and control register (spscr) see page 186. read: sprf errie ovrf modf spte modfen spr1 spr0 write: reset:00001000 $000f spi data register (spdr) see page 188. read: r7 r6 r5 r4 r3 r2 r1 r0 write: t7 t6 t5 t4 t3 t2 t1 t0 reset: unaffected by reset $0010 esci control register 1 (scc1) see page 136. read: loops ensci txinv m wake ilty pen pty write: reset:00000000 $0011 esci control register 2 (scc2) see page 138. read: sctie tcie scrie ilie te re rwu sbk write: reset:00000000 $0012 esci control register 3 (scc3) see page 141. read: r8 t8 r r orie neie feie peie write: reset:u0000000 $0013 esci status register 1 (scs1) see page 141. read: scte tc scrf idle or nf fe pe write: reset:11000000 $0014 esci status register 2 (scs2) see page 143. read: 0 0 0 0 0 0 bkf rpf write: reset:00000000 $0015 esci data register (scdr) see page 144. read: r7 r6 r5 r4 r3 r2 r1 r0 write: t7 t6 t5 t4 t3 t2 t1 t0 reset: unaffected by reset $0016 esci baud rate register (scbr) see page 144. read: lint linr scp1 scp0 r scr2 scr1 scr0 write: reset:00000000 $0017 esci prescaler register (scpsc) see page 146. read: pds2 pds1 pds0 pssb4 pssb3 pssb2 pssb1 pssb0 write: reset:00000000 $0018 esci arbiter control register (sciactl) see page 149. read: am1 r am0 aclk afin arun arovfl ard8 write: reset:00000000 addr. register name bit 7 6 5 4321bit 0 = unimplemented r = reserved u = unaffected figure 2-2. control, status, and data registers (sheet 2 of 8)
direct page registers mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 29 $0019 esci arbiter data register (sciadat) see page 150. read: ard7 ard6 ard5 ard4 ard3 ard2 ard1 ard0 write: reset:00000000 $001a keyboard status and control register (kbscr) see page 90. read: 0 0 0 0 keyf 0 imaskk modek write: ackk reset:00000000 $001b keyboard interrupt enable register (kbier) see page 90. read: 0 r kbie5 kbie4 kbie3 kbie2 kbie1 kbie0 write: reset:00000000 $001c keyboard interrupt polarity register (kbipr) see page 91. read: 0 0 kbip5 kbip4 kbip3 kbip2 kbip1 kbip0 write: reset:00000000 $001d irq status and control register (intscr) see page 83. read: 0 0 0 0 irqf 0 imask mode write: ack reset:00000000 $001e configuration register 2 (config2) (1) see page 59. read: irqpud irqen 00 tim2pos escibdsrc oscenin- stop rsten write: reset:00000000 (2) 1. one-time writable register after each reset. 2. rsten reset to 0 by a power-on reset (por) only. $001f configuration register 1 (config1) (1) see page 60. read: coprs lvistop lvirstd lvipwrd lvitrip ssrec stop copd write: reset: 0 0 0 0 0 (2) 000 1. one-time writable register after each reset. 2. lvi5or3 reset to 0 by a power-on reset (por) only. $0020 tim1 status and control register (t1sc) see page 198. read: tof toie tstop 00 ps2 ps1 ps0 write: 0 trst reset:00100000 $0021 tim1 counter register high (t1cnth) see page 199. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 $0022 tim1 counter register low (t1cntl) see page 199. read: bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 write: reset:00000000 $0023 tim1 counter modulo register high (t1modh) see page 200. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:11111111 addr. register name bit 7 6 5 4321bit 0 = unimplemented r = reserved u = unaffected figure 2-2. control, status, and data registers (sheet 3 of 8)
memory mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 30 freescale semiconductor $0024 tim1 counter modulo register low (t1modl) see page 200. read: bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 write: reset:11111111 $0025 tim1 channel 0 status and control register (t1sc0) see page 201. read: ch0f ch0ie ms0b ms0a els0b els0a tov0 ch0max write: 0 reset:00000000 $0026 tim1 channel 0 register high (t1ch0h) see page 204. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset: indeterminate after reset $0027 tim1 channel 0 register low (t1ch0l) see page 204. read: bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 write: reset: indeterminate after reset $0028 tim1 channel 1 status and control register (t1sc1) see page 198. read: ch1f ch1ie 0 ms1a els1b els1a tov1 ch1max write: 0 reset:00000000 $0029 tim1 channel 1 register high (t1ch1h) see page 204. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset: indeterminate after reset $002a tim1 channel 1 register low (t1ch1l) see page 204. read: bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 write: reset: indeterminate after reset $002b $002f reserved $0030 tim1 channel 2 status and control register (t1sc2) see page 201. read: ch2f ch2ie 0 ms2a els2b els2a tov2 ch2max write: 0 reset:00000000 $0031 tim1 channel 2 register high (t1ch2h) see page 204. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset: indeterminate after reset $0032 tim1 channel 2 register low (t1ch2l) see page 204. read: bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 write: reset: indeterminate after reset $0033 tim1 channel 3 status and control register (t1sc3) see page 201. read: ch3f ch3ie 0 ms3a els3b els3a tov3 ch3max write: 0 reset:00000000 addr. register name bit 7 6 5 4321bit 0 = unimplemented r = reserved u = unaffected figure 2-2. control, status, and data registers (sheet 4 of 8)
direct page registers mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 31 $0034 tim1 channel 3 register high (t1ch3h) see page 204. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset: indeterminate after reset $0035 tim1 channel 3 register low (t1ch3l) see page 204. read: bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 write: reset: indeterminate after reset $0036 oscillator status and control register (oscsc) see page 104. read: oscopt1 oscopt0 icfs1 icfs0 ecfs1 ecfs0 ecgon ecgst write: reset:00000000 $0037 reserved $0038 oscillator trim register (osctrim) see page 105. read: trim7 trim6 trim5 trim4 trim3 trim2 trim1 trim0 write: reset:10000000 $0039 $003b reserved $003c adc10 status and control register (adscr) see page 54. read: coco aien adco adch4 adch3 adch2 adch1 adch0 write: reset:00011111 $003d adc10 data register high (adrh) see page 56. read: 0 0 0 0 0 0 ad9 ad8 write: rrrrrrrr reset:00000000 $003e adc10 data register low (adrl) see page 56. read: ad7 ad6 ad5 ad4 ad3 ad2 ad1 ad0 write: rrrrrrrr reset:00000000 $003f adc10 clock register (adclk) see page 56. read: adlpc adiv1 adiv0 adiclk mode1 mode0 adlsmp adacken write: reset:00000000 $0240 tim2 status and control register (t2sc) see page 213. read: tof toie tstop 00 ps2 ps1 ps0 write: 0 trst reset:00100000 $0241 tim2 counter register high (t2cnth) see page 214. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 addr. register name bit 7 6 5 4321bit 0 = unimplemented r = reserved u = unaffected figure 2-2. control, status, and data registers (sheet 5 of 8)
memory mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 32 freescale semiconductor $0242 tim2 counter register low (t2cntl) see page 214. read: bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 write: reset:00000000 $0243 tim2 counter modulo register high (t2modh) see page 215. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:11111111 $0244 tim2 counter modulo register low (t2modl) see page 215. read: bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 write: reset:11111111 $0245 tim2 channel 0 status and control register (t2sc0) see page 215. read: ch0f ch0ie ms0b ms0a els0b els0a tov0 ch0max write: 0 reset:00000000 $0246 tim2 channel 0 register high (t2ch0h) see page 218. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset: indeterminate after reset $0247 tim2 channel 0 register low (t2ch0l) see page 218. read: bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 write: reset: indeterminate after reset $0248 tim2 channel 1 status and control register (t2sc1) see page 215. read: ch1f ch1ie 0 ms1a els1b els1a tov1 ch1max write: 0 reset:00000000 $0249 tim2 channel 1 register high (t2ch1h) see page 218. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset: indeterminate after reset $024a tim2 channel 1 register low (t2ch1l) see page 218. read: bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 write: reset: indeterminate after reset $024b reserved $024c periodic wakeup status and control register (pwusc) see page 119. read: 0 0 pwuon pwuclk- sel pwuf 0 pwuie smode write: pwuack reset:00000000 $024d periodic wakeup prescaler register (pwup) see page 120. read: 0 0 0 0 ps3 ps2 ps1 ps0 write: reset:00000000 $024e periodic wakeup modulo register (pwumod) see page 121. read: bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 write: reset:00000000 addr. register name bit 7 6 5 4321bit 0 = unimplemented r = reserved u = unaffected figure 2-2. control, status, and data registers (sheet 6 of 8)
direct page registers mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 33 $024f reserved $fe00 break status register (bsr) see page 223. read: rrrrrr sbsw r write: 0 reset: 0 $fe01 sim reset status register (srsr) see page 167. read: por pin cop ilop ilad modrst lvi 0 write: por: 1 0 0 00000 $fe02 break auxiliary register (brkar) see page 223. read: 0 0 0 0000 bdcop write: reset:00000000 $fe03 break flag control register (bfcr) see page 223. read: bcfe r r r rrrr write: reset: 0 $fe04 interrupt status register 1 (int1) see page 163. read: if6 if5 if4 if3 if2 if1 0 0 write: rrrrrrrr reset:00000000 $fe05 interrupt status register 2 (int2) see page 163. read: if14 if13 if12 if11 if10 if9 if8 if7 write: rrrrrrrr reset:00000000 $fe06 interrupt status register 3 (int3) see page 163. read: if22 if21 if20 if19 if18 if17 if16 if15 write: rrrrrrrr reset:00000000 $fe07 reserved $fe08 flash control register (flcr) see page 36. read: 0 0 0 0 hven mass erase pgm write: reset:00000000 $fe09 break address high register (brkh) see page 222. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 $fe0a break address low register (brkl) see page 222. read: bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 write: reset:00000000 $fe0b break status and control register (brkscr) see page 223. read: brke brka 000000 write: reset:00000000 addr. register name bit 7 6 5 4321bit 0 = unimplemented r = reserved u = unaffected figure 2-2. control, status, and data registers (sheet 7 of 8)
memory mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 34 freescale semiconductor $fe0c lvi status register (lvisr) see page 95. read: lviout 0 0 0000r write: reset:00000000 $fe0d $fe0f reserved $ffbe flash block protect register (flbpr) see page 41. read: bpr7 bpr6 bpr5 bpr4 bpr3 bpr2 bpr1 bpr0 write: reset: unaffected by reset $ffbf $ffc0 internal oscillator trim value read: trim7 trim6 trim5 trim4 trim3 trim2 trim1 trim0 write: reset: flash location with factory programmed trim value. $ffc1 $ffff cop control register (copctl) see page 65. read: low byte of reset vector write: writing clears cop counter (any value) reset: unaffected by reset addr. register name bit 7 6 5 4321bit 0 = unimplemented r = reserved u = unaffected figure 2-2. control, status, and data registers (sheet 8 of 8)
random-access memory (ram) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 35 . 2.5 random-access memory (ram) this mcu includes static ram. the locations in ram below $0100 can be accessed using the more efficient direct addressing mode, and any single bit in this area can be accessed with the bit manipulation instructions (bclr, bset, brclr, and brset). locating the most frequently accessed program variables in this area of ram is preferred. the ram retains data when the mcu is in low-power wait or stop mode. at power-on, the contents of ram are uninitialized. ram data is unaffected by any reset provided that the supply voltage does not drop below the minimum value for ram retention. for compatibility with older m68hc05 mcus, the hc08 resets the stack pointer to $00ff. in the devices that have ram above $00ff, it is usually best to reinitialize the stack pointer to the top of the ram so the direct page ram can be used for frequently accessed ram variables and bit-addressable program variables. include the following 2-instruction sequence in your reset initialization routine (where ramlast is equated to the highest address of the ram). ldhx #ramlast+1 ;point one past ram txs ;sp<-(h:x-1) table 2-1. vector addresses vector priority vector address vector lowest highest if22- if20 $ffd0- $ffd5 unused vectors (available for user program) if19 $ffd6,7 pwu vector if18 $ffd8,9 tim2 over?w vector if17 $ffda,b tim2 channel 1 vector if16 $ffdc,d tim2 channel 0 vector if15 $ffde,f adc conversion complete vector if14 $ffe0,1 keyboard vector if13 $ffe2,3 spi transmit vector if12 $ffe4,5 spi receive vector if11 $ffe6,7 esci transmit vector if10 $ffe8,9 esci receive vector if9 $ffea,b esci error vector if8 not used if7 $ffee,f tim1 channel 3 vector if6 $fff0,1 tim1 channel 2 vector if5 $fff2,3 tim1 over?w vector if4 $fff4,5 tim1 channel 1 vector if3 $fff6,7 tim1 channel 0 vector if2 not used if1 $fffa,b irq vector $fffc,d swi vector $fffe,f reset vector
memory mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 36 freescale semiconductor 2.6 flash memory (flash) the flash memory is intended primarily for program storage. in-circuit programming allows the operating program to be loaded into the flash memory after final assembly of the application product. it is possible to program the entire array through the single-wire monitor mode interface. because no special voltages are needed for flash erase and programming operations, in-application programming is also possible through other software-controlled communication paths. this subsection describes the operation of the embedded flash memory. the flash memory can be read, programmed, and erased from the internal v dd supply. the program and erase operations are enabled through the use of an internal charge pump. the minimum size of flash memory that can be erased is 64 bytes; and the maximum size of flash memory that can be programmed in a program cycle is 32 bytes (a row). program and erase operations are facilitated through control bits in the flash control register (flcr). details for these operations appear later in this section. note an erased bit reads as a 1 and a programmed bit reads as a 0. a security feature prevents viewing of the flash contents. (1) 2.6.1 flash control register the flash control register (flcr) controls flash program and erase operations. hven ?high voltage enable bit this read/write bit enables high voltage from the charge pump to the memory for either program or erase operation. it can only be set if either pgm =1 or erase =1 and the proper sequence for program or erase is followed. 1 = high voltage enabled to array and charge pump on 0 = high voltage disabled to array and charge pump off mass ?mass erase control bit this read/write bit configures the memory for mass erase operation. 1 = mass erase operation selected 0 = mass erase operation unselected erase ?erase control bit this read/write bit configures the memory for erase operation. erase is interlocked with the pgm bit such that both bits cannot be equal to 1 or set to 1 at the same time. 1 = erase operation selected 0 = erase operation unselected 1. no security feature is absolutely secure. however, freescale? strategy is to make reading or copying the flash difficult for unauthorized users. bit 7654321bit 0 read: 0000 hven mass erase pgm write: reset:00000000 = unimplemented figure 2-3. flash control register (flcr)
flash memory (flash) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 37 pgm ?program control bit this read/write bit configures the memory for program operation. pgm is interlocked with the erase bit such that both bits cannot be equal to 1 or set to 1 at the same time. 1 = program operation selected 0 = program operation unselected 2.6.2 flash page erase operation use the following procedure to erase a page of flash memory. a page consists of 64 consecutive bytes starting from addresses $xx00, $xx40, $xx80, or $xxc0. the 48-byte user interrupt vectors area also forms a page. any flash memory page can be erased alone. 1. set the erase bit and clear the mass bit in the flash control register. 2. read the flash block protect register. 3. write any data to any flash location within the address range of the block to be erased. 4. wait for a time, t nvs . 5. set the hven bit. 6. wait for a time, t erase . 7. clear the erase bit. 8. wait for a time, t nvh . 9. clear the hven bit. 10. after time, t rcv , the memory can be accessed in read mode again. note programming and erasing of flash locations cannot be performed by code being executed from the flash memory. while these operations must be performed in the order as shown, other unrelated operations may occur between the steps. note a page erase of the vector page will erase the internal oscillator trim value at $ffc0.
memory mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 38 freescale semiconductor 2.6.3 flash mass erase operation use the following procedure to erase the entire flash memory to read as a 1: 1. set both the erase bit and the mass bit in the flash control register. 2. read the flash block protect register. 3. write any data to any flash address (1) within the flash memory address range. 4. wait for a time, t nvs . 5. set the hven bit. 6. wait for a time, t merase . 7. clear the erase and mass bits. note mass erase is disabled whenever any block is protected (flbpr does not equal $ff). 8. wait for a time, t nvhl . 9. clear the hven bit. 10. after time, t rcv , the memory can be accessed in read mode again. note programming and erasing of flash locations cannot be performed by code being executed from the flash memory. while these operations must be performed in the order as shown, other unrelated operations may occur between the steps. caution a mass erase will erase the internal oscillator trim value at $ffc0. 1. when in monitor mode, with security sequence failed (see 18.3.2 security ), write to the flash block protect register in- stead of any flash address.
flash memory (flash) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 39 2.6.4 flash program operation programming of the flash memory is done on a row basis. a row consists of 32 consecutive bytes starting from addresses $xx00, $xx20, $xx40, $xx60, $xx80, $xxa0, $xxc0, or $xxe0. use the following step-by-step procedure to program a row of flash memory figure 2-4 shows a flowchart of the programming algorithm. note do not program any byte in the flash more than once after a successful erase operation. reprogramming bits to a byte which is already programmed is not allowed without first erasing the page in which the byte resides or mass erasing the entire flash memory. programming without first erasing may disturb data stored in the flash. 1. set the pgm bit. this configures the memory for program operation and enables the latching of address and data for programming. 2. read the flash block protect register. 3. write any data to any flash location within the address range desired. 4. wait for a time, t nvs . 5. set the hven bit. 6. wait for a time, t pgs . 7. write data to the flash address being programmed (1) . 8. wait for time, t prog . 9. repeat step 7 and 8 until all desired bytes within the row are programmed. 10. clear the pgm bit (1) . 11. wait for time, t nvh . 12. clear the hven bit. 13. after time, t rcv , the memory can be accessed in read mode again. this program sequence is repeated throughout the memory until all data is programmed. note programming and erasing of flash locations cannot be performed by code being executed from the flash memory. while these operations must be performed in the order shown, other unrelated operations may occur between the steps. do not exceed t prog maximum, see 19.17 memory characteristics. 1. the time between each flash address change, or the time between the last flash address programmed to clearing pgm bit, must not exceed the maximum programming time, t prog maximum.
memory mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 40 freescale semiconductor figure 2-4. flash programming flowchart set hven bit write any data to any flash address within the row address range desired wait for a time, t nvs set pgm bit wait for a time, t pgs write data to the flash address to be programmed wait for a time, t prog clear pgm bit wait for a time, t nvh clear hven bit wait for a time, t rcv completed programming this row? y n end of programming the time between each flash address change (step 7 to step 7 loop), must not exceed the maximum programming time, t prog max. or the time between the last flash address programmed to clearing pgm bit (step 7 to step 10) notes: 1 3 4 5 6 7 8 10 11 12 13 algorithm for programming a row (32 bytes) of flash memory this row program algorithm assumes the row/s to be programmed are initially erased. 9 read the flash block protect register 2
flash memory (flash) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 41 2.6.5 flash protection due to the ability of the on-board charge pump to erase and program the flash memory in the target application, provision is made to protect blocks of memory from unintentional erase or program operations due to system malfunction. this protection is done by use of a flash block protect register (flbpr). the flbpr determines the range of the flash memory which is to be protected. the range of the protected area starts from a location defined by flbpr and ends to the bottom of the flash memory ($ffff). when the memory is protected, the hven bit cannot be set in either erase or program operations. note in performing a program or erase operation, the flash block protect register must be read after setting the pgm or erase bit and before asserting the hven bit. when the flbpr is programmed with all 0 s, the entire memory is protected from being programmed and erased. when all the bits are erased (all 1?), the entire memory is accessible for program and erase. when bits within the flbpr are programmed, they lock a block of memory. the address ranges are shown in 2.6.6 flash block protect register. once the flbpr is programmed with a value other than $ff, any erase or program of the flbpr or the protected block of flash memory is prohibited. mass erase is disabled whenever any block is protected (flbpr does not equal $ff). the flbpr itself can be erased or programmed only with an external voltage, v tst , present on the irq pin. this voltage also allows entry from reset into the monitor mode. 2.6.6 flash block protect register the flash block protect register is implemented as a byte within the flash memory, and therefore can only be written during a programming sequence of the flash memory. the value in this register determines the starting address of the protected range within the flash memory. bpr[7:0] ?flash protection register bits [7:0] these eight bits in flbpr represent bits [13:6] of a 16-bit memory address. bits [15:14] are 1s and bits [5:0] are 0s. the resultant 16-bit address is used for specifying the start address of the flash memory for block protection. the flash is protected from this start address to the end of flash memory, at $ffff. with this mechanism, the protect start address can be $xx00, $xx40, $xx80, or $xxc0 within the flash memory. see figure 2-6 and table 2-2. bit 7654321bit 0 read: bpr7 bpr6 bpr5 bpr4 bpr3 bpr2 bpr1 bpr0 write: reset: unaffected by reset. initial value from factory is 1. write to this register is by a programming sequence to the flash memory. figure 2-5. flash block protect register (flbpr)
memory mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 42 freescale semiconductor figure 2-6. flash block protect start address 2.6.7 eeprom memory emulation using flash memory in some applications, the user may want to repeatedly store and read a set of data from an area of nonvolatile memory. this is easily implemented in eeprom memory because single byte erase is allowed in eeprom. when using flash memory, the minimum erase size is a page. however, the flash can be used as eeprom memory. this technique is called ?eprom emulation? the basic concept of eeprom emulation using flash is that a page is continuously programmed with a new data set without erasing the previously programmed locations. once the whole page is completely programmed or the page does not have enough bytes to program a new data set, the user software automatically erases the page and then programs a new data set in the erased page. in eeprom emulation when data is read from the page, the user software must find the latest data set in the page since the previous data still remains in the same page. there are many ways to monitor the page erase timing and the latest data set. one example is unprogrammed flash bytes are detected by checking programmed bytes (non-$ff value) in a page. in this way, the end of the data set will contain unprogrammed data ($ff value). a couple of application notes, describing how to emulate eeprom using flash, are available on our web site. titles and order numbers for these application notes are given at the end of this subsection. table 2-2. examples of protect start address bpr[7:0] start of address of protect range (1) 1. the end address of the protected range is always $ffff. $00 (2) 2. $be00?bfff is always protected unless the entire flash memory is un- protected, bpr[7:0] = $ff. the entire flash memory is protected. $01 (0000 0001 ) $c040 (1100 0000 0100 0000) $02 (0000 0010 ) $c080 (1100 0000 1000 0000) $03 (0000 0011 ) $c0c0 (11 00 0000 1100 0000) and so on... $fd (1111 1101) $ff40 (1111 1111 0100 0000) $fe ( 1111 1110) $ff80 (1111 1111 1000 0000) $ff the entire flash memory is not protected. 0 0 0 0 0 1 1 flbpr value start address of 16-bit memory address flash block protect 0
flash memory (flash) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 43 for eeprom emulation software to work successfully, the following items must be taken care of in the user software: 1. each flash byte in a page must be programmed only one time until the page is erased. 2. a page must be erased before the flash cumulative program hv period (t hv ) is beyond the maximum t hv . t hv is defined as the cumulative high-voltage programming time to the same row before the next erase. for more detailed information, refer to 19.17 memory characteristics. 3. flash row erase and program cycles should not exceed 10,000 cycles, respectively. the above eeprom emulation software can be easily developed by using the on-chip flash routines implemented in the mcu. these routines are located in the rom memory and support flash program and erase operations. proper utilization of the on-chip flash routines guarantee conformance to the flash specifications. in the on-chip flash programming routine called prgrnge, the high-voltage programming time is enabled for less than 125 s when programming a single byte at any operating bus frequency between 1.0 mhz and 8.4 mhz. therefore, even when a row is programmed by 32 separate single-byte programming operations, t hv is less than the maximum t hv . hence, item 2 listed above is already taken care of by using this routine. a page erased operation is provided in the flash erase routine called erarnge. application note an2635 ( on-chip flash programming routines ) describes how to use these routines. the following application notes, available at www.freescale.com , describe how eerpom emulation is implemented using flash: an2183 using flash as eeprom on the mc68hc908gp32 an2346 eeprom emulation using flash in mc68hc908qy/qt mcus an2690 low frequency eeprom emulation on the mc68hc908qy4 an eeprom emulation driver, available at www.freescale.com, has been developed and qualified: an3040 m68hc08 eeprom emulation driver
memory mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 44 freescale semiconductor
mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 45 chapter 3 analog-to-digital converter (adc10) module 3.1 introduction this section describes the 10-bit successive approximation analog-to-digital converter (adc10). the adc10 module shares its pins with general-purpose input/output (i/o) port pins. see figure 3-1 for port location of these shared pins. the adc10 on this mcu uses v dd and v ss as its supply and reference pins. this mcu uses busclkx4 as its alternate clock source for the adc. this mcu does not have a hardware conversion trigger. 3.2 features features of the adc10 module include: linear successive approximation algorithm with 10-bit resolution output formatted in 10- or 8-bit right-justified format single or continuous conversion (automatic power-down in single conversion mode) configurable sample time and conversion speed (to save power) conversion complete flag and interrupt input clock selectable from up to three sources operation in wait and stop modes for lower noise operation selectable asynchronous hardware conversion trigger 3.3 functional description the adc10 uses successive approximation to convert the input sample taken from advin to a digital representation. the approximation is taken and then rounded to the nearest 10- or 8-bit value to provide greater accuracy and to provide a more robust mechanism for achieving the ideal code-transition voltage. figure 3-2 shows a block diagram of the adc10
analog-to-digital converter (adc10) module mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 46 freescale semiconductor figure 3-1. block diagram highlighting adc10 block and pins all port pins can be configured with internal pullup ptc not available on 16-pin devices (see note in 11.1 introduction) ptd not available on 16-pin or 20-pin devices (see note in 11.1 introduction) pta0/t1ch0/ad0/kbi0 pta1/t1ch1/ad1/kbi1 pta2/ irq/kbi2/t1clk pta3/ rst/kbi3 pta4/osc2/ad2/kbi4 pta5/osc1/ad3/kbi5 4-channel 16-bit timer module keyboard interrupt module single interrupt module periodic wakeup low-voltage inhibit cop module 10-channel 10-bit adc enhanced serial ptb0/spsck/ad4 ptb ddrb m68hc08 cpu pta ddra ptb1/mosi/t2ch1/ad5 ptb2/miso/t2ch0/ad6 ptb3/ ss/t2clk/ad7 ptb4/rxd/t2ch0/ad8 ptb5/txd/t2ch1/ad9 ptb6/t1ch2 ptb7/t1ch3 power supply v dd v ss clock generator communications interface module module serial peripheral interface 16,384 bytes mc68hc908qc16 8192 bytes mc68hc908qc8 512 bytes mc68hc908qc16 384 bytes mc68hc908qc8 break module monitor rom 2-channel 16-bit timer module ptc0 ptc1 ptc2 ptc3 ptc ddrc ptd0 ptd ddrd ptd1 ptd2 ptd3 ptd4 ptd5 ptd6 ptd7 mc68hc908qc4 user ram user flash 4096 bytes 384 bytes mc68hc908qc4
functional description mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 47 figure 3-2. adc10 block diagram the adc10 can perform an analog-to-digital conversion on one of the software selectable channels. the output of the input multiplexer (advin) is converted by a successive approximation algorithm into a 10-bit digital result. when the conversion is completed, the result is placed in the data registers (adrh and adrl). in 8-bit mode, the result is rounded to 8 bits and placed in adrl. the conversion complete flag is then set and an interrupt request is generated if aien has been set. 3.3.1 clock select and divide circuit the clock select and divide circuit selects one of three clock sources and divides it by a configurable value to generate the input clock to the converter (adck). the clock can be selected from one of the following sources: the asynchronous clock source (aclk) this clock source is generated from a dedicated clock source which is enabled when the adc10 is converting and the clock source is selected by setting aclken. when adlpc is clear, this clock operates from 1? mhz; when adlpc is set, it operates at 0.5? mhz. this clock is not disabled in stop and allows conversions in stop mode for lower noise operation. alternate clock source ?this clock source is equal to the external oscillator clock or four times the bus clock. the alternate clock source is mcu specific, see 3.1 introduction to determine source and availability of this clock source option. this clock is selected when adiclk and aclken are both clear. the bus clock ?this clock source is equal to the bus frequency. this clock is selected when adiclk is set and aclken is clear. whichever clock is selected, its frequency must fall within the acceptable frequency range for adck. if the available clocks are too slow, the adc10 will not perform according to specifications. if the available ad0 ?? adn v refh v refl advin adch control sequencer initialize sample convert transfer abort adck bus clock alternate clock source adiclk adiv aclk adco adscr adlsmp adlpc mode complete data registers adrh:adrl sar converter aien coco interrupt aien coco 1 2 1 2 mcu stop adhwt adclk aclken async clock generator clock divide
analog-to-digital converter (adc10) module mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 48 freescale semiconductor clocks are too fast, then the clock must be divided to the appropriate frequency. this divider is specified by adiv[1:0] and can be divide-by 1, 2, 4, or 8. 3.3.2 input select and pin control only one analog input may be used for conversion at any given time. the channel select bits in adscr are used to select the input signal for conversion. 3.3.3 conversion control conversions can be performed in either 10-bit mode or 8-bit mode as determined by the mode bits. conversions can be initiated by either a software or hardware trigger. in addition, the adc10 module can be configured for low power operation, long sample time, and continuous conversion. 3.3.3.1 initiating conversions a conversion is initiated: following a write to adscr (with adch bits not all 1s) if software triggered operation is selected. following a hardware trigger event if hardware triggered operation is selected. following the transfer of the result to the data registers when continuous conversion is enabled. if continuous conversions are enabled a new conversion is automatically initiated after the completion of the current conversion. in software triggered operation, continuous conversions begin after adscr is written and continue until aborted. in hardware triggered operation, continuous conversions begin after a hardware trigger event and continue until aborted. 3.3.3.2 completing conversions a conversion is completed when the result of the conversion is transferred into the data result registers, adrh and adrl. this is indicated by the setting of coco. an interrupt request is generated if aien is set at the time that coco is set. a blocking mechanism prevents a new result from overwriting previous data in adrh and adrl if the previous data is in the process of being read while in 10-bit mode (adrh has been read but adrl has not). in this case the data transfer is blocked, coco is not set, and the new result is lost. when a data transfer is blocked, another conversion is initiated regardless of the state of adco (single or continuous conversions enabled). if single conversions are enabled, this could result in several discarded conversions and excess power consumption. to avoid this issue, the data registers must not be read after initiating a single conversion until the conversion completes. 3.3.3.3 aborting conversions any conversion in progress will be aborted when: a write to adscr occurs (the current conversion will be aborted and a new conversion will be initiated, if adch are not all 1s). a write to adclk occurs. the mcu is reset. the mcu enters stop mode with aclk not enabled.
functional description mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 49 when a conversion is aborted, the contents of the data registers, adrh and adrl, are not altered but continue to be the values transferred after the completion of the last successful conversion. in the case that the conversion was aborted by a reset, adrh and adrl return to their reset states. upon reset or when a conversion is otherwise aborted, the adc10 module will enter a low power, inactive state. in this state, all internal clocks and references are disabled. this state is entered asynchronously and immediately upon aborting of a conversion. 3.3.3.4 total conversion time the total conversion time depends on many factors such as sample time, bus frequency, whether aclken is set, and synchronization time. the total conversion time is summarized in table 3-1 . the maximum total conversion time for a single conversion or the first conversion in continuous conversion mode is determined by the clock source chosen and the divide ratio selected. the clock source is selectable by adiclk and aclken, and the divide ratio is specified by adiv. for example, if the alternative clock source is 16 mhz and is selected as the input clock source, the input clock divide-by-8 ratio is selected and the bus frequency is 4 mhz, then the conversion time for a single 10-bit conversion is: note the adck frequency must be between f adck minimum and f adck maximum to meet a/d specifications. table 3-1. total conversion time versus control conditions conversion mode aclken maximum conversion time 8-bit mode (short sample ?adlsmp = 0): single or 1st continuous single or 1st continuous subsequent continuous (f bus  f adck ) 0 1 x 18 adck + 3 bus clock 18 adck + 3 bus clock + 5 s 16 adck 8-bit mode (long sample ?adlsmp = 1): single or 1st continuous single or 1st continuous subsequent continuous (f bus  f adck ) 0 1 x 38 adck + 3 bus clock 38 adck + 3 bus clock + 5 s 36 adck 10-bit mode (short sample ?adlsmp = 0): single or 1st continuous single or 1st continuous subsequent continuous (f bus  f adck ) 0 1 x 21 adck + 3 bus clock 21 adck + 3 bus clock + 5 s 19 adck 10-bit mode (long sample ?adlsmp = 1): single or 1st continuous single or 1st continuous subsequent continuous (f bus  f adck ) 0 1 x 41 adck + 3 bus clock 41 adck + 3 bus clock + 5 s 39 adck 21 adck cycles conversion time = 16 mhz/8 number of bus cycles = 11.25 s x 4 mhz = 45 cycles 3 bus cycles 4 mhz + = 11.25 s
analog-to-digital converter (adc10) module mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 50 freescale semiconductor 3.3.4 sources of error several sources of error exist for adc conversions. these are discussed in the following sections. 3.3.4.1 sampling error for proper conversions, the input must be sampled long enough to achieve the proper accuracy. given the maximum input resistance of approximately 15 k ? and input capacitance of approximately 10 pf, sampling to within 1/4 lsb (at 10-bit resolution) can be achieved within the minimum sample window (3.5 cycles / 2 mhz maximum adck frequency) provided the resistance of the external analog source (r as ) is kept below 10 k?. higher source resistances or higher-accuracy sampling is possible by setting adlsmp (to increase the sample window to 23.5 cycles) or decreasing adck frequency to increase sample time. 3.3.4.2 pin leakage error leakage on the i/o pins can cause conversion error if the external analog source resistance (r as ) is high. if this error cannot be tolerated by the application, keep r as lower than v advin / (4096*i leak ) for less than 1/4 lsb leakage error (at 10-bit resolution). 3.3.4.3 noise-induced errors system noise which occurs during the sample or conversion process can affect the accuracy of the conversion. the adc10 accuracy numbers are guaranteed as specified only if the following conditions are met: there is a 0.1 f low-esr capacitor from v refh to v refl (if available). there is a 0.1 f low-esr capacitor from v dda to v ssa (if available). if inductive isolation is used from the primary supply, an additional 1 f capacitor is placed from v dda to v ssa (if available). ? ssa and v refl (if available) is connected to v ss at a quiet point in the ground plane. the mcu is placed in wait mode immediately after initiating the conversion (next instruction after write to adscr). there is no i/o switching, input or output, on the mcu during the conversion. there are some situations where external system activity causes radiated or conducted noise emissions or excessive v dd noise is coupled into the adc10. in these cases, or when the mcu cannot be placed in wait or i/o activity cannot be halted, the following recommendations may reduce the effect of noise on the accuracy: place a 0.01 f capacitor on the selected input channel to v refl or v ssa (if available). this will improve noise issues but will affect sample rate based on the external analog source resistance. operate the adc10 in stop mode by setting aclken, selecting the channel in adscr, and executing a stop instruction. this will reduce v dd noise but will increase effective conversion time due to stop recovery. average the input by converting the output many times in succession and dividing the sum of the results. four samples are required to eliminate the effect of a 1 lsb , one-time error. reduce the effect of synchronous noise by operating off the asynchronous clock (aclken=1) and averaging. noise that is synchronous to the adck cannot be averaged out.
functional description mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 51 3.3.4.4 code width and quantization error the adc10 quantizes the ideal straight-line transfer function into 1024 steps (in 10-bit mode). each step ideally has the same height (1 code) and width. the width is defined as the delta between the transition points from one code to the next. the ideal code width for an n bit converter (in this case n can be 8 or 10), defined as 1 lsb , is: 1 lsb = (v refh ? refl ) / 2 n because of this quantization, there is an inherent quantization error. because the converter performs a conversion and then rounds to 8 or 10 bits, the code will transition when the voltage is at the midpoint between the points where the straight line transfer function is exactly represented by the actual transfer function. therefore, the quantization error will be 1/2 lsb in 8- or 10-bit mode. as a consequence, however, the code width of the first ($000) conversion is only 1/2 lsb and the code width of the last ($ff or $3ff) is 1.5 lsb . 3.3.4.5 linearity errors the adc10 may also exhibit non-linearity of several forms. every effort has been made to reduce these errors but the user should be aware of them because they affect overall accuracy. these errors are: zero-scale error (e zs ) (sometimes called offset) this error is defined as the difference between the actual code width of the first conversion and the ideal code width (1/2 lsb ). note, if the first conversion is $001, then the difference between the actual $001 code width and its ideal (1 lsb )is used. full-scale error (e fs ) ?this error is defined as the difference between the actual code width of the last conversion and the ideal code width (1.5 lsb ). note, if the last conversion is $3fe, then the difference between the actual $3fe code width and its ideal (1 lsb ) is used. differential non-linearity (dnl) this error is defined as the worst-case difference between the actual code width and the ideal code width for all conversions. integral non-linearity (inl) this error is defined as the highest-value the (absolute value of the) running sum of dnl achieves. more simply, this is the worst-case difference of the actual transition voltage to a given code and its corresponding ideal transition voltage, for all codes. total unadjusted error (tue) this error is defined as the difference between the actual transfer function and the ideal straight-line transfer function, and therefore includes all forms of error. 3.3.4.6 code jitter, non-monotonicity and missing codes analog-to-digital converters are susceptible to three special forms of error. these are code jitter, non-monotonicity, and missing codes. code jitter is when, at certain points, a given input voltage converts to one of two values when sampled repeatedly. ideally, when the input voltage is infinitesimally smaller than the transition voltage, the converter yields the lower code (and vice-versa). however, even very small amounts of system noise can cause the converter to be indeterminate (between two codes) for a range of input voltages around the transition voltage. this range is normally around 1/2 lsb but will increase with noise. non-monotonicity is defined as when, except for code jitter, the converter converts to a lower code for a higher input voltage. missing codes are those which are never converted for any input value. in 8-bit or 10-bit mode, the adc10 is guaranteed to be monotonic and to have no missing codes.
analog-to-digital converter (adc10) module mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 52 freescale semiconductor 3.4 interrupts when aien is set, the adc10 is capable of generating an interrupt request after each conversion. an interrupt request is generated when the conversion completes (indicated by coco being set). coco will set at the end of a conversion regardless of the state of aien. 3.5 low-power modes the wait and stop instructions put the mcu in low power-consumption standby modes. 3.5.1 wait mode the adc10 will continue the conversion process and will generate an interrupt request following a conversion if aien is set. if the adc10 is not required in wait mode, power down the adc by setting the channel select bits (adch[4:0]) to all 1s to enter a low power state before executing the wait instruction. 3.5.2 stop mode if aclken is clear, executing a stop instruction will abort the current conversion and place the adc10 in a low-power state. upon return from stop mode, a write to adscr is required to resume conversions, and the result stored in adrh and adrl will represent the last completed conversion until the new conversion completes. if aclken is set, the adc10 continues normal operation during stop mode. the adc10 will continue the conversion process and will generate an interrupt following a conversion if aien is set. if the adc10 is not required to bring the mcu out of stop mode, ensure that the adc10 is not in continuous conversion mode by clearing adco in the adc10 status and control register before executing the stop instruction. in single conversion mode the adc10 automatically enters a low-power state when the conversion is complete. it is not necessary to set the channel select bits (adch[4:0]) to all 1s to enter a low-power state. if aclken is set, a conversion can be initiated while in stop using the external hardware trigger adextco when in external convert mode. the adc10 will operate in a low-power mode until the trigger is asserted, at which point it will perform a conversion and assert the interrupt when complete (if aien is set). 3.6 adc10 during break interrupts the system integration module (sim) controls whether status bits in other modules can be cleared during the break state. bcfe in the break flag control register (bfcr) enables software to clear status bits during the break state. see bfcr in the sim section of this data sheet. to allow software to clear status bits during a break interrupt, write a 1 to bcfe. if a status bit is cleared during the break state, it remains cleared when the mcu exits the break state. to protect status bits during the break state, write a 0 to bcfe. with bcfe cleared (its default state), software can read and write registers during the break state without affecting status bits. some status bits have a two-step read/write clearing procedure. if software does the first step on such a bit before the break, the bit cannot change during the break state as long as bcfe is cleared. after the break, doing the second step clears the status bit.
i/o signals mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 53 3.7 i/o signals the adc10 module shares its pins with general-purpose input/output (i/o) port pins. see figure 3-1 for port location of these shared pins. the adc10 on this mcu uses v dd and v ss as its supply and reference pins. this mcu does not have an external trigger source. 3.7.1 adc10 analog power pin (v dda ) the adc10 analog portion uses v dda as its power pin. in some packages, v dda is connected internally to v dd . if externally available, connect the v dda pin to the same voltage potential as v dd . external filtering may be necessary to ensure clean v dda for good results. note if externally available, route v dda carefully for maximum noise immunity and place bypass capacitors as near as possible to the package. 3.7.2 adc10 analog ground pin (v ssa ) the adc10 analog portion uses v ssa as its ground pin. in some packages, v ssa is connected internally to v ss . if externally available, connect the v ssa pin to the same voltage potential as v ss . in cases where separate power supplies are used for analog and digital power, the ground connection between these supplies should be at the v ssa pin. this should be the only ground connection between these supplies if possible. the v ssa pin makes a good single point ground location. 3.7.3 adc10 voltage reference high pin (v refh ) v refh is the power supply for setting the high-reference voltage for the converter. in some packages, v refh is connected internally to v dda . if externally available, v refh may be connected to the same potential as v dda , or may be driven by an external source that is between the minimum v dda spec and the v dda potential (v refh must never exceed v dda ). note route v refh carefully for maximum noise immunity and place bypass capacitors as near as possible to the package. ac current in the form of current spikes required to supply charge to the capacitor array at each successive approximation step is drawn through the v refh and v refl loop. the best external component to meet this current demand is a 0.1 f capacitor with good high frequency characteristics. this capacitor is connected between v refh and v refl and must be placed as close as possible to the package pins. resistance in the path is not recommended because the current will cause a voltage drop which could result in conversion errors. inductance in this path must be minimum (parasitic only). 3.7.4 adc10 voltage reference low pin (v refl ) v refl is the power supply for setting the low-reference voltage for the converter. in some packages, v refl is connected internally to v ssa . if externally available, connect the v refl pin to the same voltage potential as v ssa . there will be a brief current associated with v refl when the sampling capacitor is charging. if externally available, connect the v refl pin to the same potential as v ssa at the single point ground location.
analog-to-digital converter (adc10) module mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 54 freescale semiconductor 3.7.5 adc10 channel pins (adn) the adc10 has multiple input channels. empirical data shows that capacitors on the analog inputs improve performance in the presence of noise or when the source impedance is high. 0.01 f capacitors with good high-frequency characteristics are sufficient. these capacitors are not necessary in all cases, but when used they must be placed as close as possible to the package pins and be referenced to v ssa . 3.8 registers these registers control and monitor operation of the adc10: adc10 status and control register, adscr adc10 data registers, adrh and adrl adc10 clock register, adclk 3.8.1 adc10 status and control register this section describes the function of the adc10 status and control register (adscr). writing adscr aborts the current conversion and initiates a new conversion (if the adch[4:0] bits are equal to a value other than all 1s). coco ?conversion complete bit coco is a read-only bit which is set each time a conversion is completed. this bit is cleared whenever the status and control register is written or whenever the data register (low) is read. 1 = conversion completed 0 = conversion not completed aien ?adc10 interrupt enable bit when this bit is set, an interrupt is generated at the end of a conversion. the interrupt signal is cleared when the data register is read or the status/control register is written. 1 = adc10 interrupt enabled 0 = adc10 interrupt disabled adco ?adc10 continuous conversion bit when this bit is set, the adc10 will begin to convert samples continuously (continuous conversion mode) and update the result registers at the end of each conversion, provided adch[4:0] do not decode to all 1s. the adc10 will continue to convert until the mcu enters reset, the mcu enters stop mode (if aclken is clear), adclk is written, or until adscr is written again. if stop is entered (with aclken low), continuous conversions will cease and can be restarted only with a write to adscr. any write to adscr with adco set and the adch bits not all 1s will abort the current conversion and begin continuous conversions. bit 7654321bit 0 read: coco aien adco adch4 adch3 adch2 adch1 adch0 write: reset:00011111 = unimplemented figure 3-3. adc10 status and control register (adscr)
registers mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 55 if the bus frequency is less than the adck frequency, precise sample time for continuous conversions cannot be guaranteed in short-sample mode (adlsmp = 0). if the bus frequency is less than 1/11th of the adck frequency, precise sample time for continuous conversions cannot be guaranteed in long-sample mode (adlsmp = 1). when clear, the adc10 will perform a single conversion (single conversion mode) each time adscr is written (assuming adch[4:0] do not decode all 1s). 1 = continuous conversion following a write to adscr 0 = one conversion following a write to adscr adch[4:0] ?channel select bits the adch[4:0] bits form a 5-bit field that is used to select one of the input channels. the input channels are detailed in table 3-2 . the successive approximation converter subsystem is turned off when the channel select bits are all set to 1. this feature allows explicit disabling of the adc10 and isolation of the input channel from the i/o pad. terminating continuous conversion mode this way will prevent an additional, single conversion from being performed. it is not necessary to set the channel select bits to all 1s to place the adc10 in a low-power state, however, because the module is automatically placed in a low-power state when a conversion completes. table 3-2. input channel select adch4 adch3 adch2 adch1 adch0 input select (1) 1. if any unused or reserved channels are selected, the resulting conversion will be unknown. 00000 ad0 00001 ad1 00010 ad2 00011 ad3 00100 ad4 00101 ad5 00110 ad6 00111 ad7 01000 un used continuing through unused 10111 un used 11000 ad8 11001 ad9 11010 bandgap ref (2) 2. requires lvi to be powered (lvipwrd =0, in config1) 11011 reserved 11100 reserved 11101 v refh 11110 v refl 11111lo w-power state
analog-to-digital converter (adc10) module mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 56 freescale semiconductor 3.8.2 adc10 result high register (adrh) this register holds the msbs of the result and is updated each time a conversion completes. all other bits read as 0s. reading adrh prevents the adc10 from transferring subsequent conversion results into the result registers until adrl is read. if adrl is not read until the after next conversion is completed, then the intermediate conversion result will be lost. in 8-bit mode, this register contains no interlocking with adrl. 3.8.3 adc10 result low register (adrl) this register holds the lsbs of the result. this register is updated each time a conversion completes. reading adrh prevents the adc10 from transferring subsequent conversion results into the result registers until adrl is read. if adrl is not read until the after next conversion is completed, then the intermediate conversion result will be lost. in 8-bit mode, there is no interlocking with adrh. 3.8.4 adc10 clock register (adclk) this register selects the clock frequency for the adc10 and the modes of operation. bit 7654321bit 0 read: 00000000 write: reset:00000000 = unimplemented figure 3-4. adc10 data register high (adrh), 8-bit mode bit 7654321bit 0 read: 000000ad9ad8 write: reset:00000000 = unimplemented figure 3-5. adc10 data register high (adrh), 10-bit mode bit 7654321bit 0 read: ad7 ad6 ad5 ad4 ad3 ad2 ad1 ad0 write: reset:00000000 = unimplemented figure 3-6. adc10 data register low (adrl) bit 7654321bit 0 read: adlpc adiv1 adiv0 adiclk mode1 mode0 adlsmp aclken write: reset:00000000 figure 3-7. adc10 clock register (adclk)
registers mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 57 adlpc ?adc10 low-power configuration bit adlpc controls the speed and power configuration of the successive approximation converter. this is used to optimize power consumption when higher sample rates are not required. 1 = low-power configuration: the power is reduced at the expense of maximum clock speed. 0 = high-speed configuration adiv[1:0] ?adc10 clock divider bits adiv1 and adiv0 select the divide ratio used by the adc10 to generate the internal clock adck. table 3-3 shows the available clock configurations. adiclk ?input clock select bit if aclken is clear, adiclk selects either the bus clock or an alternate clock source as the input clock source to generate the internal clock adck. if the alternate clock source is less than the minimum clock speed, use the internally-generated bus clock as the clock source. as long as the internal clock adck, which is equal to the selected input clock divided by adiv, is at a frequency (f adck ) between the minimum and maximum clock speeds (considering alpc), correct operation can be guaranteed. 1 = the internal bus clock is selected as the input clock source 0 = the alternate clock source is selected mode[1:0] ?10- or 8-bit or hardware triggered mode selection these bits select 10- or 8-bit operation. the successive approximation converter generates a result that is rounded to 8- or 10-bit value based on the mode selection. this rounding process sets the transfer function to transition at the midpoint between the ideal code voltages, causing a quantization error of 1/2 lsb . reset returns 8-bit mode. 00 = 8-bit, right-justified, adscr software triggered mode enabled 01 = 10-bit, right-justified, adscr software triggered mode enabled 10 = reserved 11 = 10-bit, right-justified, hardware triggered mode enabled adlsmp ?long sample time configuration this bit configures the sample time of the adc10 to either 3.5 or 23.5 adck clock cycles. this adjusts the sample period to allow higher impedance inputs to be accurately sampled or to maximize conversion speed for lower impedance inputs. longer sample times can also be used to lower overall power consumption in continuous conversion mode if high conversion rates are not required. 1 = long sample time (23.5 cycles) 0 = short sample time (3.5 cycles) table 3-3. adc10 clock divide ratio adiv1 adiv0 divide ratio (adiv) clock rate 0 0 1 input clock 1 0 1 2 input clock 2 1 0 4 input clock 4 1 1 8 input clock 8
analog-to-digital converter (adc10) module mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 58 freescale semiconductor aclken ?asynchronous clock source enable this bit enables the asynchronous clock source as the input clock to generate the internal clock adck, and allows operation in stop mode. the asynchronous clock source will operate between 1 mhz and 2 mhz if adlpc is clear, and between 0.5 mhz and 1 mhz if adlpc is set. 1 = the asynchronous clock is selected as the input clock source (the clock generator is only enabled during the conversion) 0 = adiclk specifies the input clock source and conversions will not continue in stop mode
mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 59 chapter 4 configuration registers (config1 and config2) 4.1 introduction this section describes the configuration registers (config1 and config2). the configuration registers enable or disable the following options: stop mode recovery time (32 busclkx4 cycles or 4096 busclkx4 cycles) stop instruction computer operating properly module (cop) cop reset period (coprs): 8176 busclkx4 or 262,128 busclkx4 low-voltage inhibit (lvi) enable and trip voltage selection allow clock source to remain enabled in stop enable irq pin disable irq pin pullup device enable rst pin clock source selection for the enhanced serial communication interface (esci) module reposition tim2 timer channels 4.2 functional description the configuration registers are used in the initialization of various options. the configuration registers can be written once after each reset. most of the configuration register bits are cleared during reset. since the various options affect the operation of the microcontroller unit (mcu) it is recommended that this register be written immediately after reset. the configuration registers are located at $001e and $001f, and may be read at anytime. note the config registers are one-time writable by the user after each reset. upon a reset, the config registers default to predetermined settings as shown in figure 4-1 and figure 4-2 . bit 7 6 5 4 3 2 1 bit 0 read: irqpud irqen 00 tim2pos escibd- src oscenin stop rsten write: reset: 0 0 0 0 0 0 0 u por: 0 0 0 0 0 0 0 0 = unimplemented u = unaffected figure 4-1. configuration register 2 (config2)
configuration registers (config1 and config2) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 60 freescale semiconductor irqpud irq pin pullup control bit 1 = internal pullup is disconnected 0 = internal pullup is connected between irq pin and v dd irqen irq pin function selection bit 1 = interrupt request function active in pin 0 = interrupt request function inactive in pin tim2pos ?tim2 position bit tim2pos is used to reposition the timer channels for tim2 to a different pair of pins. this allows the user to free up one of the communication ports based on application needs. 1 = tim2 timer channel pins share ptb4 and ptb5 0 = tim2 timer channel pins share ptb1 and ptb2 escibdsrc ?esci baud rate clock source bit escibdsrc controls the clock source used for the esci. the setting of the bit affects the frequency at which the esci operates. 1 = internal data bus clock used as clock source for esci 0 = busclkx4 used as clock source for esci osceninstop?oscillator enable in stop mode bit osceninstop, when set, will allow the clock source to continue to generate clocks in stop mode. this function can be used to keep the periodic wakeup running while the rest of the microcontroller stops. when clear, the clock source is disabled when the microcontroller enters stop mode. 1 = oscillator enabled to operate during stop mode 0 = oscillator disabled during stop mode rsten rst pin function selection 1 = reset function active in pin 0 = reset function inactive in pin note the rsten bit is cleared by a power-on reset (por) only. other resets will leave this bit unaffected. coprs ?cop reset period selection bit 1 = cop reset short cycle = 8176 busclkx4 0 = cop reset long cycle = 262,128 busclkx4 bit 7 6 5 4 3 2 1 bit 0 read: coprs lvistop lvirstd lvipwrd lvitrip ssrec stop copd write: reset:0000u000 por: 0 0 0 0 0000 u = unaffected figure 4-2. configuration register 1 (config1)
functional description mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 61 lvistop ?lvi enable in stop mode bit when the lvipwrd bit is clear, setting the lvistop bit enables the lvi to operate during stop mode. reset clears lvistop. 1 = lvi enabled during stop mode 0 = lvi disabled during stop mode lvirstd ?lvi reset disable bit lvirstd disables the reset signal from the lvi module. 1 = lvi module resets disabled 0 = lvi module resets enabled lvipwrd ?lvi power disable bit lvipwrd disables the lvi module. 1 = lvi module power disabled 0 = lvi module power enabled lvitrip ?lvi trip point selection bit lvitrip selects the voltage operating mode of the lvi module. the voltage mode selected for the lvi should match the operating v dd for the lvi? voltage trip points for each of the modes. 1 = lvi operates for a 5-v protection 0 = lvi operates for a 3.3-v protection note the lvitrip bit is cleared by a power-on reset (por) only. other resets will leave this bit unaffected. ssrec ?short stop recovery bit ssrec enables the cpu to exit stop mode with a delay of 32 busclkx4 cycles instead of a 4096 busclkx4 cycle delay. 1 = stop mode recovery after 32 busclkx4 cycles 0 = stop mode recovery after 4096 busclkx4 cycles note exiting stop mode by an lvi reset will result in the long stop recovery. when using the lvi during normal operation but disabling during stop mode, the lvi will have an enable time of t en . the system stabilization time for power-on reset and long stop recovery (both 4096 busclkx4 cycles) gives a delay longer than the lvi enable time for these startup scenarios. there is no period where the mcu is not protected from a low-power condition. however, when using the short stop recovery configuration option, the 32 busclkx4 delay must be greater than the lvi? turn on time to avoid a period in startup where the lvi is not protecting the mcu. stop ?stop instruction enable bit stop enables the stop instruction. 1 = stop instruction enabled 0 = stop instruction treated as illegal opcode copd ?cop disable bit copd disables the cop module. 1 = cop module disabled 0 = cop module enabled
configuration registers (config1 and config2) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 62 freescale semiconductor
mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 63 chapter 5 computer operating properly (cop) 5.1 introduction the computer operating properly (cop) module contains a free-running counter that generates a reset if allowed to overflow. the cop module helps software recover from runaway code. prevent a cop reset by clearing the cop counter periodically. the cop module can be disabled through the copd bit in the configuration 1 (config1) register. 5.2 functional description figure 5-1. cop block diagram 1. see chapter 14 system integration module (sim) for more details. copctl write busclkx4 stop instruction sim reset circuit reset status register internal reset sources (1) sim module clear stages 5?2 12-bit sim counter clear all stages copd (from config1) reset copctl write clear cop module copen (from sim) cop clock cop timeout cop rate select (coprs from config1) 6-bit cop counter cop counter
computer operating properly (cop) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 64 freescale semiconductor the cop counter is a free-running 6-bit counter preceded by the 12-bit system integration module (sim) counter. if not cleared by software, the cop counter overflows and generates an asynchronous reset after 262,128 or 8176 busclkx4 cycles; depending on the state of the cop rate select bit, coprs, in configuration register 1. with a 262,128 busclkx4 cycle overflow option, the internal 12.8-mhz oscillator gives a cop timeout period of 20.48 ms. writing any value to location $ffff before an overflow occurs prevents a cop reset by clearing the cop counter and stages 12? of the sim counter. note service the cop immediately after reset and before entering or after exiting stop mode to guarantee the maximum time before the first cop counter overflow. a cop reset pulls the rst pin low (if the rsten bit is set in the config1 register) for 32 busclkx4 cycles and sets the cop bit in the reset status register (rsr). see 14.8.1 sim reset status register. note place cop clearing instructions in the main program and not in an interrupt subroutine. such an interrupt subroutine could keep the cop from generating a reset even while the main program is not working properly. 5.3 i/o signals the following paragraphs describe the signals shown in figure 5-1. 5.3.1 busclkx4 busclkx4 is the oscillator output signal. busclkx4 frequency is equal to the crystal frequency, internal oscillator frequency, or the rc-oscillator frequency. 5.3.2 stop instruction the stop instruction clears the sim counter. 5.3.3 copctl write writing any value to the cop control register (copctl) (see 5.4 cop control register ) clears the cop counter and clears stages 12? of the sim counter. reading the cop control register returns the low byte of the reset vector. 5.3.4 power-on reset the power-on reset (por) circuit in the sim clears the sim counter 4096 busclkx4 cycles after power up. 5.3.5 internal reset an internal reset clears the sim counter and the cop counter. 5.3.6 copd (cop disable) the copd signal reflects the state of the cop disable bit (copd) in the configuration register (config). see chapter 4 configuration registers (config1 and config2) .
cop control register mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 65 5.3.7 coprs (cop rate select) the coprs signal reflects the state of the cop rate select bit (coprs) in the configuration register 1 (config1). see chapter 4 configuration registers (config1 and config2). 5.4 cop control register the cop control register (copctl) is located at address $ffff and overlaps the reset vector. writing any value to $ffff clears the cop counter and starts a new timeout period. reading location $ffff returns the low byte of the reset vector. 5.5 interrupts the cop does not generate cpu interrupt requests. 5.6 monitor mode the cop is disabled in monitor mode when v tst is present on the irq pin. 5.7 low-power modes the wait and stop instructions put the mcu in low power-consumption standby modes. 5.7.1 wait mode the cop continues to operate during wait mode. to prevent a cop reset during wait mode, periodically clear the cop counter. 5.7.2 stop mode stop mode turns off the busclkx4 input to the cop and clears the sim counter. service the cop immediately before entering or after exiting stop mode to ensure a full cop timeout period after entering or exiting stop mode. 5.8 cop module during break mode the cop is disabled during a break interrupt with monitor mode when bdcop bit is set in break auxiliary register (brkar). bit 7654321bit 0 read: low byte of reset vector write: clear cop counter reset: unaffected by reset figure 5-2. cop control register (copctl)
computer operating properly (cop) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 66 freescale semiconductor
mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 67 chapter 6 central processor unit (cpu) 6.1 introduction the m68hc08 cpu (central processor unit) is an enhanced and fully object-code-compatible version of the m68hc05 cpu. the cpu08 reference manual (document order number cpu08rm/ad) contains a description of the cpu instruction set, addressing modes, and architecture. 6.2 features features of the cpu include: object code fully upward-compatible with m68hc05 family 16-bit stack pointer with stack manipulation instructions 16-bit index register with x-register manipulation instructions 8-mhz cpu internal bus frequency 64-kbyte program/data memory space 16 addressing modes memory-to-memory data moves without using accumulator fast 8-bit by 8-bit multiply and 16-bit by 8-bit divide instructions enhanced binary-coded decimal (bcd) data handling modular architecture with expandable internal bus definition for extension of addressing range beyond 64 kbytes low-power stop and wait modes 6.3 cpu registers figure 6-1 shows the five cpu registers. cpu registers are not part of the memory map.
central processor unit (cpu) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 68 freescale semiconductor figure 6-1. cpu registers 6.3.1 accumulator the accumulator is a general-purpose 8-bit register. the cpu uses the accumulator to hold operands and the results of arithmetic/logic operations. 6.3.2 index register the 16-bit index register allows indexed addressing of a 64-kbyte memory space. h is the upper byte of the index register, and x is the lower byte. h:x is the concatenated 16-bit index register. in the indexed addressing modes, the cpu uses the contents of the index register to determine the conditional address of the operand. the index register can serve also as a temporary data storage location. bit 7654321bit 0 read: write: reset: unaffected by reset figure 6-2. accumulator (a) bit 151413121110987654321 bit 0 read: write: reset:00000000 xxxxxxxx x = indeterminate figure 6-3. index register (h:x) accumulator (a) index register (h:x) stack pointer (sp) program counter (pc) condition code register (ccr) carry/borrow flag zero flag negative flag interrupt mask half-carry flag two? complement overflow flag v11hinzc h x 0 0 0 0 7 15 15 15 70
cpu registers mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 69 6.3.3 stack pointer the stack pointer is a 16-bit register that contains the address of the next location on the stack. during a reset, the stack pointer is preset to $00ff. the reset stack pointer (rsp) instruction sets the least significant byte to $ff and does not affect the most significant byte. the stack pointer decrements as data is pushed onto the stack and increments as data is pulled from the stack. in the stack pointer 8-bit offset and 16-bit offset addressing modes, the stack pointer can function as an index register to access data on the stack. the cpu uses the contents of the stack pointer to determine the conditional address of the operand. note the location of the stack is arbitrary and may be relocated anywhere in random-access memory (ram). moving the sp out of page 0 ($0000 to $00ff) frees direct address (page 0) space. for correct operation, the stack pointer must point only to ram locations. 6.3.4 program counter the program counter is a 16-bit register that contains the address of the next instruction or operand to be fetched. normally, the program counter automatically increments to the next sequential memory location every time an instruction or operand is fetched. jump, branch, and interrupt operations load the program counter with an address other than that of the next sequential location. during reset, the program counter is loaded with the reset vector address located at $fffe and $ffff. the vector address is the address of the first instruction to be executed after exiting the reset state. bit 151413121110987654321 bit 0 read: write: reset:0000000011111111 figure 6-4. stack pointer (sp) bit 151413121110987654321 bit 0 read: write: reset: loaded with vector from $fffe and $ffff figure 6-5. program counter (pc)
central processor unit (cpu) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 70 freescale semiconductor 6.3.5 condition code register the 8-bit condition code register contains the interrupt mask and five flags that indicate the results of the instruction just executed. bits 6 and 5 are set permanently to 1. the following paragraphs describe the functions of the condition code register. v ?overflow flag the cpu sets the overflow flag when a two's complement overflow occurs. the signed branch instructions bgt, bge, ble, and blt use the overflow flag. 1 = overflow 0 = no overflow h ?half-carry flag the cpu sets the half-carry flag when a carry occurs between accumulator bits 3 and 4 during an add-without-carry (add) or add-with-carry (adc) operation. the half-carry flag is required for binary-coded decimal (bcd) arithmetic operations. the daa instruction uses the states of the h and c flags to determine the appropriate correction factor. 1 = carry between bits 3 and 4 0 = no carry between bits 3 and 4 i ?interrupt mask when the interrupt mask is set, all maskable cpu interrupts are disabled. cpu interrupts are enabled when the interrupt mask is cleared. when a cpu interrupt occurs, the interrupt mask is set automatically after the cpu registers are saved on the stack, but before the interrupt vector is fetched. 1 = interrupts disabled 0 = interrupts enabled note to maintain m6805 family compatibility, the upper byte of the index register (h) is not stacked automatically. if the interrupt service routine modifies h, then the user must stack and unstack h using the pshh and pulh instructions. after the i bit is cleared, the highest-priority interrupt request is serviced first. a return-from-interrupt (rti) instruction pulls the cpu registers from the stack and restores the interrupt mask from the stack. after any reset, the interrupt mask is set and can be cleared only by the clear interrupt mask software instruction (cli). n ?negative flag the cpu sets the negative flag when an arithmetic operation, logic operation, or data manipulation produces a negative result, setting bit 7 of the result. 1 = negative result 0 = non-negative result bit 7654321bit 0 read: v11hinzc write: reset: x 1 1 x 1 x x x x = indeterminate figure 6-6. condition code register (ccr)
arithmetic/logic unit (alu) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 71 z ?zero flag the cpu sets the zero flag when an arithmetic operation, logic operation, or data manipulation produces a result of $00. 1 = zero result 0 = non-zero result c ?carry/borrow flag the cpu sets the carry/borrow flag when an addition operation produces a carry out of bit 7 of the accumulator or when a subtraction operation requires a borrow. some instructions such as bit test and branch, shift, and rotate ?also clear or set the carry/borrow flag. 1 = carry out of bit 7 0 = no carry out of bit 7 6.4 arithmetic/logic unit (alu) the alu performs the arithmetic and logic operations defined by the instruction set. refer to the cpu08 reference manual (document order number cpu08rm/ad) for a description of the instructions and addressing modes and more detail about the architecture of the cpu. 6.5 low-power modes the wait and stop instructions put the mcu in low pow er-consumption standby modes. 6.5.1 wait mode the wait instruction: clears the interrupt mask (i bit) in the condition code register, enabling interrupts. after exit from wait mode by interrupt, the i bit remains clear. after exit by reset, the i bit is set. disables the cpu clock 6.5.2 stop mode the stop instruction: clears the interrupt mask (i bit) in the condition code register, enabling external interrupts. after exit from stop mode by external interrupt, the i bit remains clear. after exit by reset, the i bit is set. disables the cpu clock after exiting stop mode, the cpu clock begins running after the oscillator stabilization delay. 6.6 cpu during break interrupts if a break module is present on the mcu, the cpu starts a break interrupt by: loading the instruction register with the swi instruction loading the program counter with $fffc:$fffd or with $fefc:$fefd in monitor mode the break interrupt begins after completion of the cpu instruction in progress. if the break address register match occurs on the last cycle of a cpu instruction, the break interrupt begins immediately. a return-from-interrupt instruction (rti) in the break routine ends the break interrupt and returns the mcu to normal operation if the break interrupt has been deasserted.
central processor unit (cpu) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 72 freescale semiconductor 6.7 instruction set summary table 6-1 provides a summary of the m68hc08 instruction set. table 6-1. instruction set summary (sheet 1 of 6) source form operation description effect on ccr address mode opcode operand cycles vh i nzc adc #opr adc opr adc opr adc opr ,x adc opr ,x adc ,x adc opr ,sp adc opr ,sp add with carry a (a) + (m) + (c) ?? ??? imm dir ext ix2 ix1 ix sp1 sp2 a9 b9 c9 d9 e9 f9 9ee9 9ed9 ii dd hh ll ee ff ff ff ee ff 2 3 4 4 3 2 4 5 add #opr add opr add opr add opr ,x add opr ,x add ,x add opr ,sp add opr ,sp add without carry a (a) + (m) ?? ??? imm dir ext ix2 ix1 ix sp1 sp2 ab bb cb db eb fb 9eeb 9edb ii dd hh ll ee ff ff ff ee ff 2 3 4 4 3 2 4 5 ais # opr add immediate value (signed) to sp sp (sp) + (16 m) imm a7 ii 2 aix # opr add immediate value (signed) to h:x h:x (h:x) + (16 m) imm af ii 2 and #opr and opr and opr and opr ,x and opr ,x and ,x and opr ,sp and opr ,sp logical and a (a) & (m) 0 ?? imm dir ext ix2 ix1 ix sp1 sp2 a4 b4 c4 d4 e4 f4 9ee4 9ed4 ii dd hh ll ee ff ff ff ee ff 2 3 4 4 3 2 4 5 asl opr asla aslx asl opr ,x asl ,x asl opr ,sp arithmetic shift left (same as lsl) ? ??? dir inh inh ix1 ix sp1 38 48 58 68 78 9e68 dd ff ff 4 1 1 4 3 5 asr opr asra asrx asr opr ,x asr opr ,x asr opr ,sp arithmetic shift right ? ??? dir inh inh ix1 ix sp1 37 47 57 67 77 9e67 dd ff ff 4 1 1 4 3 5 bcc rel branch if carry bit clear pc (pc) + 2 + rel ? (c) = 0 rel 24 rr 3 bclr n , opr clear bit n in m mn 0 dir (b0) dir (b1) dir (b2) dir (b3) dir (b4) dir (b5) dir (b6) dir (b7) 11 13 15 17 19 1b 1d 1f dd dd dd dd dd dd dd dd 4 4 4 4 4 4 4 4 bcs rel br anch if carry bit set (same as blo) pc (pc) + 2 + rel ? (c) = 1 rel 25 rr 3 beq rel branch if equal pc (pc) + 2 + rel ? (z) = 1 rel 27 rr 3 bge opr branch if greater than or equal to (signed operands) pc (pc) + 2 + rel ? (n v) = 0 rel 90 rr 3 bgt opr branch if greater than (signed operands) pc (pc) + 2 + rel ? (z) | (n v) = 0 rel 92 rr 3 bhcc rel branch if half carry bit clear pc (pc) + 2 + rel ? (h) = 0 rel 28 rr 3 bhcs rel branch if half carry bit set pc (pc) + 2 + rel ? (h) = 1 rel 29 rr 3 bhi rel branch if higher pc (pc) + 2 + rel ? (c) | (z) = 0 rel 22 rr 3 c b0 b7 0 b0 b7 c
instruction set summary mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 73 bhs rel branch if higher or same (same as bcc) pc (pc) + 2 + rel ? (c) = 0 rel 24 rr 3 bih rel branch if irq pin high pc (pc) + 2 + rel ? irq = 1 rel 2f rr 3 bil rel branch if irq pin low pc (pc) + 2 + rel ? irq = 0 rel 2e rr 3 bit #opr bit opr bit opr bit opr ,x bit opr ,x bit ,x bit opr ,sp bit opr ,sp bit test (a) & (m) 0 ?? imm dir ext ix2 ix1 ix sp1 sp2 a5 b5 c5 d5 e5 f5 9ee5 9ed5 ii dd hh ll ee ff ff ff ee ff 2 3 4 4 3 2 4 5 ble opr branch if less than or equal to (signed operands) pc (pc) + 2 + rel ? (z) | (n v ) = 1 rel 93 rr 3 blo rel branch if lower (same as bcs) pc (pc) + 2 + rel ? (c) = 1 rel 25 rr 3 bls rel branch if lower or same pc (pc) + 2 + rel ? (c) | (z) = 1 rel 23 rr 3 blt opr branch if less than (signed operands) pc (pc) + 2 + rel ? (n v) =1 rel 91 rr 3 bmc rel branch if interrupt mask clear pc (pc) + 2 + rel ? (i) = 0 rel 2c rr 3 bmi rel branch if minus pc (pc) + 2 + rel ? (n) = 1 rel 2b rr 3 bms rel branch if interrupt mask set pc (pc) + 2 + rel ? (i) = 1 rel 2d rr 3 bne rel branch if not equal pc (pc) + 2 + rel ? (z) = 0 rel 26 rr 3 bpl rel branch if plus pc (pc) + 2 + rel ? (n) = 0 rel 2a rr 3 bra rel branch always pc (pc) + 2 + rel rel 20 rr 3 brclr n, opr , rel branch if bit n in m clear pc (pc) + 3 + rel ? (mn) = 0 ? dir (b0) dir (b1) dir (b2) dir (b3) dir (b4) dir (b5) dir (b6) dir (b7) 01 03 05 07 09 0b 0d 0f dd rr dd rr dd rr dd rr dd rr dd rr dd rr dd rr 5 5 5 5 5 5 5 5 brn rel branch never pc (pc) + 2 rel 21 rr 3 brset n, opr , rel branch if bit n in m set pc (pc) + 3 + rel ? (mn) = 1 ? dir (b0) dir (b1) dir (b2) dir (b3) dir (b4) dir (b5) dir (b6) dir (b7) 00 02 04 06 08 0a 0c 0e dd rr dd rr dd rr dd rr dd rr dd rr dd rr dd rr 5 5 5 5 5 5 5 5 bset n , opr set bit n in m mn 1 dir (b0) dir (b1) dir (b2) dir (b3) dir (b4) dir (b5) dir (b6) dir (b7) 10 12 14 16 18 1a 1c 1e dd dd dd dd dd dd dd dd 4 4 4 4 4 4 4 4 bsr rel branch to subroutine pc (pc) + 2; push (pcl) sp (sp) ?1; push (pch) sp (sp) ?1 pc (pc) + rel rel ad rr 4 cbeq opr,rel cbeqa # opr,rel cbeqx # opr,rel cbeq opr, x+ ,rel cbeq x+ ,rel cbeq opr, sp ,rel compare and branch if equal pc (pc) + 3 + rel ? (a) ?(m) = $00 pc (pc) + 3 + rel ? (a) ?(m) = $00 pc (pc) + 3 + rel ? (x) ?(m) = $00 pc (pc) + 3 + rel ? (a) ?(m) = $00 pc (pc) + 2 + rel ? (a) ?(m) = $00 pc (pc) + 4 + rel ? (a) ?(m) = $00 dir imm imm ix1+ ix+ sp1 31 41 51 61 71 9e61 dd rr ii rr ii rr ff rr rr ff rr 5 4 4 5 4 6 clc clear carry bit c 0 0 inh 98 1 cli clear interrupt mask i 0 0 inh 9a 2 table 6-1. instruction set summary (sheet 2 of 6) source form operation description effect on ccr address mode opcode operand cycles vh i nzc
central processor unit (cpu) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 74 freescale semiconductor clr opr clra clrx clrh clr opr ,x clr ,x clr opr ,sp clear m $00 a $00 x $00 h $00 m $00 m $00 m $00 001 dir inh inh inh ix1 ix sp1 3f 4f 5f 8c 6f 7f 9e6f dd ff ff 3 1 1 1 3 2 4 cmp # opr cmp opr cmp opr cmp opr ,x cmp opr ,x cmp ,x cmp opr ,sp cmp opr ,sp compare a with m (a) ?(m) ? ??? imm dir ext ix2 ix1 ix sp1 sp2 a1 b1 c1 d1 e1 f1 9ee1 9ed1 ii dd hh ll ee ff ff ff ee ff 2 3 4 4 3 2 4 5 com opr coma comx com opr ,x com ,x com opr ,sp complement (ones complement) m ( m) = $ff ?(m) a ( a) = $ff ?(m) x ( x) = $ff ?(m) m ( m) = $ff ?(m) m ( m) = $ff ?(m) m ( m) = $ff ?(m) 0 ?? 1 dir inh inh ix1 ix sp1 33 43 53 63 73 9e63 dd ff ff 4 1 1 4 3 5 cphx # opr cphx opr compare h:x with m (h:x) ?(m:m + 1) ? ??? imm dir 65 75 ii ii+1 dd 3 4 cpx #opr cpx opr cpx opr cpx ,x cpx opr ,x cpx opr ,x cpx opr ,sp cpx opr ,sp compare x with m (x) ?(m) ? ??? imm dir ext ix2 ix1 ix sp1 sp2 a3 b3 c3 d3 e3 f3 9ee3 9ed3 ii dd hh ll ee ff ff ff ee ff 2 3 4 4 3 2 4 5 daa decimal adjust a (a) 10 u ??? inh 72 2 dbnz opr,rel dbnza rel dbnzx rel dbnz opr, x,rel dbnz x ,rel dbnz opr, sp ,rel decrement and branch if not zero a (a) 1 or m (m) 1 or x (x) 1 pc (pc) + 3 + rel ? (result) 0 pc (pc) + 2 + rel ? (result) 0 pc (pc) + 2 + rel ? (result) 0 pc (pc) + 3 + rel ? (result) 0 pc (pc) + 2 + rel ? (result) 0 pc (pc) + 4 + rel ? (result) 0 dir inh inh ix1 ix sp1 3b 4b 5b 6b 7b 9e6b dd rr rr rr ff rr rr ff rr 5 3 3 5 4 6 dec opr deca decx dec opr ,x dec ,x dec opr ,sp decrement m (m) ?1 a (a) ?1 x (x) ?1 m (m) ?1 m (m) ?1 m (m) ?1 ? ?? dir inh inh ix1 ix sp1 3a 4a 5a 6a 7a 9e6a dd ff ff 4 1 1 4 3 5 div divide a (h:a)/(x) h remainder ?? inh 52 7 eor # opr eor opr eor opr eor opr ,x eor opr ,x eor ,x eor opr ,sp eor opr ,sp exclusive or m with a a (a m) 0 ?? imm dir ext ix2 ix1 ix sp1 sp2 a8 b8 c8 d8 e8 f8 9ee8 9ed8 ii dd hh ll ee ff ff ff ee ff 2 3 4 4 3 2 4 5 inc opr inca incx inc opr ,x inc ,x inc opr ,sp increment m (m) + 1 a (a) + 1 x (x) + 1 m (m) + 1 m (m) + 1 m (m) + 1 ? ?? dir inh inh ix1 ix sp1 3c 4c 5c 6c 7c 9e6c dd ff ff 4 1 1 4 3 5 table 6-1. instruction set summary (sheet 3 of 6) source form operation description effect on ccr address mode opcode operand cycles vh i nzc
instruction set summary mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 75 jmp opr jmp opr jmp opr ,x jmp opr ,x jmp ,x jump pc jump address dir ext ix2 ix1 ix bc cc dc ec fc dd hh ll ee ff ff 2 3 4 3 2 jsr opr jsr opr jsr opr ,x jsr opr ,x jsr ,x jump to subroutine pc (pc) + n (n = 1, 2, or 3) push (pcl); sp (sp) ?1 push (pch); sp (sp) ?1 pc unconditional address dir ext ix2 ix1 ix bd cd dd ed fd dd hh ll ee ff ff 4 5 6 5 4 lda # opr lda opr lda opr lda opr ,x lda opr ,x lda ,x lda opr ,sp lda opr ,sp load a from m a (m) 0 ?? imm dir ext ix2 ix1 ix sp1 sp2 a6 b6 c6 d6 e6 f6 9ee6 9ed6 ii dd hh ll ee ff ff ff ee ff 2 3 4 4 3 2 4 5 ldhx # opr ldhx opr load h:x from m h:x ( m:m + 1 ) 0 ?? imm dir 45 55 ii jj dd 3 4 ldx #opr ldx opr ldx opr ldx opr ,x ldx opr ,x ldx ,x ldx opr ,sp ldx opr ,sp load x from m x (m) 0 ?? imm dir ext ix2 ix1 ix sp1 sp2 ae be ce de ee fe 9eee 9ede ii dd hh ll ee ff ff ff ee ff 2 3 4 4 3 2 4 5 lsl opr lsla lslx lsl opr ,x lsl ,x lsl opr ,sp logical shift left (same as asl) ? ??? dir inh inh ix1 ix sp1 38 48 58 68 78 9e68 dd ff ff 4 1 1 4 3 5 lsr opr lsra lsrx lsr opr ,x lsr ,x lsr opr ,sp logical shift right ? 0 ?? dir inh inh ix1 ix sp1 34 44 54 64 74 9e64 dd ff ff 4 1 1 4 3 5 mo v opr,opr mov opr, x+ mov # opr,opr mov x+ ,opr move (m) destination (m) source h:x (h:x) + 1 (ix+d, dix+) 0 ?? dd dix+ imd ix+d 4e 5e 6e 7e dd dd dd ii dd dd 5 4 4 4 mul unsigned multiply x:a (x) (a) 0 0 inh 42 5 neg opr nega negx neg opr ,x neg ,x neg opr ,sp negate (twos complement) m ?m) = $00 ?(m) a ?a) = $00 ?(a) x ?x) = $00 ?(x) m ?m) = $00 ?(m) m ?m) = $00 ?(m) ? ??? dir inh inh ix1 ix sp1 30 40 50 60 70 9e60 dd ff ff 4 1 1 4 3 5 nop no operation none inh 9d 1 nsa nibble swap a a (a[3:0]:a[7:4]) inh 62 3 ora # opr ora opr ora opr ora opr ,x ora opr ,x ora ,x ora opr ,sp ora opr ,sp inclusive or a and m a (a) | (m) 0 ?? imm dir ext ix2 ix1 ix sp1 sp2 aa ba ca da ea fa 9eea 9eda ii dd hh ll ee ff ff ff ee ff 2 3 4 4 3 2 4 5 psha push a onto stack push (a); sp (sp) ?1 inh 87 2 pshh push h onto stack push (h); sp (sp) ?1 inh 8b 2 pshx push x onto stack push (x); sp (sp) ?1 inh 89 2 table 6-1. instruction set summary (sheet 4 of 6) source form operation description effect on ccr address mode opcode operand cycles vh i nzc c b0 b7 0 b0 b7 c 0
central processor unit (cpu) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 76 freescale semiconductor pula pull a from stack sp (sp + 1); pull ( a) inh 86 2 pulh pull h from stack sp (sp + 1); pull ( h) inh 8a 2 pulx pull x from stack sp (sp + 1); pull ( x) inh 88 2 rol opr rola rolx rol opr ,x rol ,x rol opr ,sp rotate left through carry ? ??? dir inh inh ix1 ix sp1 39 49 59 69 79 9e69 dd ff ff 4 1 1 4 3 5 ror opr rora rorx ror opr ,x ror ,x ror opr ,sp rotate right through carry ? ??? dir inh inh ix1 ix sp1 36 46 56 66 76 9e66 dd ff ff 4 1 1 4 3 5 rsp reset stack pointer sp $ff inh 9c 1 rti return from interrupt sp (sp) + 1; pull (ccr) sp (sp) + 1; pull (a) sp (sp) + 1; pull (x) sp (sp) + 1; pull (pch) sp (sp) + 1; pull (pcl) ?????? inh 80 7 rts return from subroutine sp sp + 1 ; pull ( pch) sp sp + 1; pull (pcl) inh 81 4 sbc #opr sbc opr sbc opr sbc opr ,x sbc opr ,x sbc ,x sbc opr ,sp sbc opr ,sp subtr act with carry a (a) ?(m) ?(c) ? ??? imm dir ext ix2 ix1 ix sp1 sp2 a2 b2 c2 d2 e2 f2 9ee2 9ed2 ii dd hh ll ee ff ff ff ee ff 2 3 4 4 3 2 4 5 sec set carry bit c 1 1 inh 99 1 sei set interrupt mask i 1 1 inh 9b 2 sta opr sta opr sta opr ,x sta opr ,x sta ,x sta opr ,sp sta opr ,sp store a in m m (a) 0 ?? dir ext ix2 ix1 ix sp1 sp2 b7 c7 d7 e7 f7 9ee7 9ed7 dd hh ll ee ff ff ff ee ff 3 4 4 3 2 4 5 sthx opr store h:x in m (m:m + 1) (h:x) 0 ?? dir 35 dd 4 stop enable interrupts, stop processing, refer to mcu documentation i 0; stop processing 0 inh 8e 1 stx opr stx opr stx opr ,x stx opr ,x stx ,x stx opr ,sp stx opr ,sp store x in m m (x) 0 ?? dir ext ix2 ix1 ix sp1 sp2 bf cf df ef ff 9eef 9edf dd hh ll ee ff ff ff ee ff 3 4 4 3 2 4 5 sub #opr sub opr sub opr sub opr ,x sub opr ,x sub ,x sub opr ,sp sub opr ,sp subtract a (a) ?(m) ? ??? imm dir ext ix2 ix1 ix sp1 sp2 a0 b0 c0 d0 e0 f0 9ee0 9ed0 ii dd hh ll ee ff ff ff ee ff 2 3 4 4 3 2 4 5 table 6-1. instruction set summary (sheet 5 of 6) source form operation description effect on ccr address mode opcode operand cycles vh i nzc c b0 b7 b0 b7 c
opcode map mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 77 6.8 opcode map see table 6-2. swi software interrupt pc (pc) + 1; push (pcl) sp (sp) ?1; push (pch) sp (sp) ?1; push (x) sp (sp) ?1; push (a) sp (sp) ?1; push (ccr) sp (sp) ?1; i 1 pch interrupt vector high byte pcl interrupt vector low byte 1inh 83 9 tap transfer a to ccr ccr (a) ?????? inh 84 2 tax transfer a to x x (a) inh 97 1 tpa transfer ccr to a a (ccr) inh 85 1 tst opr tsta tstx tst opr ,x tst ,x tst opr ,sp test for negative or zero (a) ?$00 or (x) ?$00 or (m) ?$00 0 ?? dir inh inh ix1 ix sp1 3d 4d 5d 6d 7d 9e6d dd ff ff 3 1 1 3 2 4 tsx transfer sp to h:x h:x (sp) + 1 inh 95 2 txa transfer x to a a (x) inh 9f 1 txs transfer h:x to sp (sp) (h:x) ?1 inh 94 2 wait enable interrupts; wait for interrupt i bit 0; inhibit cpu clocking until interrupted 0inh 8f 1 a accumulator n any bit c carry/borrow bit opr operand (one or two bytes) ccr condition code register pc program counter dd direct address of operand pch program counter high byte dd rr direct address of operand and relative offset of branch instruction pcl program counter low byte dd direct to direct addressing mode rel relative addressing mode dir direct addressing mode rel relative program counter offset byte dix+ direct to indexed with post increment addressing mode rr relative program counter offset byte ee ff high and low bytes of offset in indexed, 16-bit offset addressing sp1 stack pointer, 8-bit offset addressing mode ext extended addressing mode sp2 stack pointer 16-bit offset addressing mode ff offset byte in indexed, 8-bit offset addressing sp stack pointer h half-carry bit u unde?ed h index register high byte v over?w bit hh ll high and low bytes of operand address in extended addressing x index register low byte i interrupt mask z zero bit ii immediate operand byte & logical and imd immediate source to direct destination addressing mode | logical or imm immediate addressing mode logical exclusive or inh inherent addressing mode ( ) contents of ix indexed, no offset addressing mode ? ) negation (twos complement) ix+ indexed, no offset, post increment addressing mode # immediate value ix+d indexed with post increment to direct addressing mode sign extend ix1 indexed, 8-bit offset addressing mode loaded with ix1+ indexed, 8-bit offset, post increment addressing mode ? if ix2 indexed, 16-bit offset addressing mode : concatenated with m memory location ? set or cleared n negative bit not affected table 6-1. instruction set summary (sheet 6 of 6) source form operation description effect on ccr address mode opcode operand cycles vh i nzc
mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 78 freescale semiconductor central processor unit (cpu) table 6-2. opcode map bit manipulation branch read-modify-write control register/memory dir dir rel dir inh inh ix1 sp1 ix inh inh imm dir ext ix2 sp2 ix1 sp1 ix 0 1234569e6789abcd9ede9eef 0 5 brset0 3 dir 4 bset0 2 dir 3 bra 2 rel 4 neg 2 dir 1 nega 1 inh 1 negx 1 inh 4 neg 2 ix1 5 neg 3 sp1 3 neg 1ix 7 rti 1 inh 3 bge 2 rel 2 sub 2 imm 3 sub 2 dir 4 sub 3 ext 4 sub 3 ix2 5 sub 4 sp2 3 sub 2 ix1 4 sub 3 sp1 2 sub 1ix 1 5 brclr0 3 dir 4 bclr0 2 dir 3 brn 2 rel 5 cbeq 3 dir 4 cbeqa 3 imm 4 cbeqx 3 imm 5 cbeq 3 ix1+ 6 cbeq 4 sp1 4 cbeq 2 ix+ 4 rts 1 inh 3 blt 2 rel 2 cmp 2 imm 3 cmp 2 dir 4 cmp 3 ext 4 cmp 3 ix2 5 cmp 4 sp2 3 cmp 2 ix1 4 cmp 3 sp1 2 cmp 1ix 2 5 brset1 3 dir 4 bset1 2 dir 3 bhi 2 rel 5 mul 1 inh 7 div 1 inh 3 nsa 1 inh 2 daa 1 inh 3 bgt 2 rel 2 sbc 2 imm 3 sbc 2 dir 4 sbc 3 ext 4 sbc 3 ix2 5 sbc 4 sp2 3 sbc 2 ix1 4 sbc 3 sp1 2 sbc 1ix 3 5 brclr1 3 dir 4 bclr1 2 dir 3 bls 2 rel 4 com 2 dir 1 coma 1 inh 1 comx 1 inh 4 com 2 ix1 5 com 3 sp1 3 com 1ix 9 swi 1 inh 3 ble 2 rel 2 cpx 2 imm 3 cpx 2 dir 4 cpx 3 ext 4 cpx 3 ix2 5 cpx 4 sp2 3 cpx 2 ix1 4 cpx 3 sp1 2 cpx 1ix 4 5 brset2 3 dir 4 bset2 2 dir 3 bcc 2 rel 4 lsr 2 dir 1 lsra 1 inh 1 lsrx 1 inh 4 lsr 2 ix1 5 lsr 3 sp1 3 lsr 1ix 2 ta p 1 inh 2 txs 1 inh 2 and 2 imm 3 and 2 dir 4 and 3 ext 4 and 3 ix2 5 and 4 sp2 3 and 2 ix1 4 and 3 sp1 2 and 1ix 5 5 brclr2 3 dir 4 bclr2 2 dir 3 bcs 2 rel 4 sthx 2 dir 3 ldhx 3 imm 4 ldhx 2 dir 3 cphx 3 imm 4 cphx 2 dir 1 tpa 1 inh 2 tsx 1 inh 2 bit 2 imm 3 bit 2 dir 4 bit 3 ext 4 bit 3 ix2 5 bit 4 sp2 3 bit 2 ix1 4 bit 3 sp1 2 bit 1ix 6 5 brset3 3 dir 4 bset3 2 dir 3 bne 2 rel 4 ror 2 dir 1 rora 1 inh 1 rorx 1 inh 4 ror 2 ix1 5 ror 3 sp1 3 ror 1ix 2 pula 1 inh 2 lda 2 imm 3 lda 2 dir 4 lda 3 ext 4 lda 3 ix2 5 lda 4 sp2 3 lda 2 ix1 4 lda 3 sp1 2 lda 1ix 7 5 brclr3 3 dir 4 bclr3 2 dir 3 beq 2 rel 4 asr 2 dir 1 asra 1 inh 1 asrx 1 inh 4 asr 2 ix1 5 asr 3 sp1 3 asr 1ix 2 psha 1 inh 1 ta x 1 inh 2 ais 2 imm 3 sta 2 dir 4 sta 3 ext 4 sta 3 ix2 5 sta 4 sp2 3 sta 2 ix1 4 sta 3 sp1 2 sta 1ix 8 5 brset4 3 dir 4 bset4 2 dir 3 bhcc 2 rel 4 lsl 2 dir 1 lsla 1 inh 1 lslx 1 inh 4 lsl 2 ix1 5 lsl 3 sp1 3 lsl 1ix 2 pulx 1 inh 1 clc 1 inh 2 eor 2 imm 3 eor 2 dir 4 eor 3 ext 4 eor 3 ix2 5 eor 4 sp2 3 eor 2 ix1 4 eor 3 sp1 2 eor 1ix 9 5 brclr4 3 dir 4 bclr4 2 dir 3 bhcs 2 rel 4 rol 2 dir 1 rola 1 inh 1 rolx 1 inh 4 rol 2 ix1 5 rol 3 sp1 3 rol 1ix 2 pshx 1 inh 1 sec 1 inh 2 adc 2 imm 3 adc 2 dir 4 adc 3 ext 4 adc 3 ix2 5 adc 4 sp2 3 adc 2 ix1 4 adc 3 sp1 2 adc 1ix a 5 brset5 3 dir 4 bset5 2 dir 3 bpl 2 rel 4 dec 2 dir 1 deca 1 inh 1 decx 1 inh 4 dec 2 ix1 5 dec 3 sp1 3 dec 1ix 2 pulh 1 inh 2 cli 1 inh 2 ora 2 imm 3 ora 2 dir 4 ora 3 ext 4 ora 3 ix2 5 ora 4 sp2 3 ora 2 ix1 4 ora 3 sp1 2 ora 1ix b 5 brclr5 3 dir 4 bclr5 2 dir 3 bmi 2 rel 5 dbnz 3 dir 3 dbnza 2 inh 3 dbnzx 2 inh 5 dbnz 3 ix1 6 dbnz 4 sp1 4 dbnz 2ix 2 pshh 1 inh 2 sei 1 inh 2 add 2 imm 3 add 2 dir 4 add 3 ext 4 add 3 ix2 5 add 4 sp2 3 add 2 ix1 4 add 3 sp1 2 add 1ix c 5 brset6 3 dir 4 bset6 2 dir 3 bmc 2 rel 4 inc 2 dir 1 inca 1 inh 1 incx 1 inh 4 inc 2 ix1 5 inc 3 sp1 3 inc 1ix 1 clrh 1 inh 1 rsp 1 inh 2 jmp 2 dir 3 jmp 3 ext 4 jmp 3 ix2 3 jmp 2 ix1 2 jmp 1ix d 5 brclr6 3 dir 4 bclr6 2 dir 3 bms 2 rel 3 tst 2 dir 1 tsta 1 inh 1 tstx 1 inh 3 tst 2 ix1 4 tst 3 sp1 2 tst 1ix 1 nop 1 inh 4 bsr 2 rel 4 jsr 2 dir 5 jsr 3 ext 6 jsr 3 ix2 5 jsr 2 ix1 4 jsr 1ix e 5 brset7 3 dir 4 bset7 2 dir 3 bil 2 rel 5 mov 3dd 4 mov 2 dix+ 4 mov 3 imd 4 mov 2 ix+d 1 stop 1 inh * 2 ldx 2 imm 3 ldx 2 dir 4 ldx 3 ext 4 ldx 3 ix2 5 ldx 4 sp2 3 ldx 2 ix1 4 ldx 3 sp1 2 ldx 1ix f 5 brclr7 3 dir 4 bclr7 2 dir 3 bih 2 rel 3 clr 2 dir 1 clra 1 inh 1 clrx 1 inh 3 clr 2 ix1 4 clr 3 sp1 2 clr 1ix 1 wait 1 inh 1 txa 1 inh 2 aix 2 imm 3 stx 2 dir 4 stx 3 ext 4 stx 3 ix2 5 stx 4 sp2 3 stx 2 ix1 4 stx 3 sp1 2 stx 1ix inh inherent rel relative sp1 stack pointer, 8-bit offset imm immediate ix indexed, no offset sp2 stack pointer, 16-bit offset dir direct ix1 indexed, 8-bit offset ix+ indexed, no offset with ext extended ix2 indexed, 16-bit offset post increment dd direct-direct imd immediate-direct ix1+ indexed, 1-byte offset with ix+d indexed-direct dix+ direct-indexed post increment * pre-byte for stack pointer indexed instructions 0 high byte of opcode in hexadecimal low byte of opcode in hexadecimal 0 5 brset0 3 dir cycles opcode mnemonic number of bytes / addressing mode msb lsb msb lsb
mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 79 chapter 7 external interrupt (irq) 7.1 introduction the irq (external interrupt) module provides a maskable interrupt input. irq functionality is enabled by setting configuration register 2 (config2) irqen bit accordingly. a zero disables the irq function and irq will assume the other shared functionalities. a one enables the irq function. see chapter 4 configuration registers (config1 and config2) for more information on enabling the irq pin. the irq pin shares its pin with general-purpose input/output (i/o) port pins. see figure 7-1 for port location of this shared pin. 7.2 features features of the irq module include: a dedicated external interrupt pin irq irq interrupt control bits programmable edge-only or edge and level interrupt sensitivity automatic interrupt acknowledge internal pullup device 7.3 functional description a low level applied to the external interrupt request ( irq) pin can latch a cpu interrupt request. figure 7-2 shows the structure of the irq module. interrupt signals on the irq pin are latched into the irq latch. the irq latch remains set until one of the following actions occurs: irq vector fetch. an irq vector fetch automatically generates an interrupt acknowledge signal that clears the latch that caused the vector fetch. software clear. software can clear the irq latch by writing a 1 to the ack bit in the interrupt status and control register (intscr). reset. a reset automatically clears the irq latch. the external irq pin is falling edge sensitive out of reset and is software-configurable to be either falling edge or falling edge and low level sensitive. the mode bit in intscr controls the triggering sensitivity of the irq pin.
external interrupt (irq) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 80 freescale semiconductor figure 7-1. block diagram highlighting irq block and pin all port pins can be configured with internal pullup ptc not available on 16-pin devices (see note in 11.1 introduction) ptd not available on 16-pin or 20-pin devices (see note in 11.1 introduction) pta0/t1ch0/ad0/kbi0 pta1/t1ch1/ad1/kbi1 pta2/ irq/kbi2/t1clk pta3/ rst/kbi3 pta4/osc2/ad2/kbi4 pta5/osc1/ad3/kbi5 4-channel 16-bit timer module keyboard interrupt module single interrupt module periodic wakeup low-voltage inhibit cop module 10-channel 10-bit adc enhanced serial ptb0/spsck/ad4 ptb ddrb m68hc08 cpu pta ddra ptb1/mosi/t2ch1/ad5 ptb2/miso/t2ch0/ad6 ptb3/ ss/t2clk/ad7 ptb4/rxd/t2ch0/ad8 ptb5/txd/t2ch1/ad9 ptb6/t1ch2 ptb7/t1ch3 power supply v dd v ss clock generator communications interface module module serial peripheral interface 16,384 bytes mc68hc908qc16 8192 bytes mc68hc908qc8 512 bytes mc68hc908qc16 384 bytes mc68hc908qc8 break module monitor rom 2-channel 16-bit timer module ptc0 ptc1 ptc2 ptc3 ptc ddrc ptd0 ptd ddrd ptd1 ptd2 ptd3 ptd4 ptd5 ptd6 ptd7 mc68hc908qc4 user ram user flash 4096 bytes 384 bytes mc68hc908qc4
functional description mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 81 when set, the imask bit in intscr masks the irq interrupt request. a latched interrupt request is not presented to the interrupt priority logic unless imask is clear. note the interrupt mask (i) in the condition code register (ccr) masks all interrupt requests, including the irq interrupt request. a falling edge on the irq pin can latch an interrupt request into the irq latch. an irq vector fetch, software clear, or reset clears the irq latch. figure 7-2. irq module block diagram 7.3.1 mode = 1 if the mode bit is set, the irq pin is both falling edge sensitive and low level sensitive. with mode set, both of the following actions must occur to clear the irq interrupt request: return of the irq pin to a high level. as long as the irq pin is low, the irq request remains active. irq vector fetch or software clear. an irq vector fetch generates an interrupt acknowledge signal to clear the irq latch. software generates the interrupt acknowledge signal by writing a 1 to ack in intscr. the ack bit is useful in applications that poll the irq pin and require software to clear the irq latch. writing to ack prior to leaving an interrupt service routine can also prevent spurious interrupts due to noise. setting ack does not affect subsequent transitions on the irq pin. a falling edge that occurs after writing to ack latches another interrupt request. if the irq mask bit, imask, is clear, the cpu loads the program counter with the irq vector address. the irq vector fetch or software clear and the return of the irq pin to a high level may occur in any order. the interrupt request remains pending as long as the irq pin is low. a reset will clear the irq latch and the mode control bit, thereby clearing the interrupt even if the pin stays low. use the bih or bil instruction to read the logic level on the irq pin. imask dq ck clr irq high interrupt to mode select logic request v dd mode voltage detect irqf to cpu for bil/bih instructions internal address bus reset v dd internal pullup device ack irq synchronizer irq vector fetch decoder irq latch
external interrupt (irq) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 82 freescale semiconductor 7.3.2 mode = 0 if the mode bit is clear, the irq pin is falling edge sensitive only. with mode clear, an irq vector fetch or software clear immediately clears the irq latch. the irqf bit in intscr can be read to check for pending interrupts. the irqf bit is not affected by imask, which makes it useful in applications where polling is preferred. note when using the level-sensitive interrupt trigger, avoid false irq interrupts by masking interrupt requests in the interrupt routine. 7.4 interrupts the following irq source can generate interrupt requests: interrupt flag (irqf) the irqf bit is set when the irq pin is asserted based on the irq mode. the irq interrupt mask bit, imask, is used to enable or disable irq interrupt requests. 7.5 low-power modes the wait and stop instructions put the mcu in low power-consumption standby modes. 7.5.1 wait mode the irq module remains active in wait mode. clearing imask in intscr enables irq interrupt requests to bring the mcu out of wait mode. 7.5.2 stop mode the irq module remains active in stop mode. clearing imask in intscr enables irq interrupt requests to bring the mcu out of stop mode. 7.6 irq module during break interrupts the system integration module (sim) controls whether status bits in other modules can be cleared during the break state. the bcfe bit in the break flag control register (bfcr) enables software to clear status bits during the break state. see bfcr in the sim section of this data sheet. to allow software to clear status bits during a break interrupt, write a 1 to bcfe. if a status bit is cleared during the break state, it remains cleared when the mcu exits the break state. to protect status bits during the break state, write a 0 to bcfe. with bcfe cleared (its default state), software can read and write registers during the break state without affecting status bits. some status bits have a two-step read/write clearing procedure. if software does the first step on such a bit before the break, the bit cannot change during the break state as long as bcfe is cleared. after the break, doing the second step clears the status bit.
i/o signals mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 83 7.7 i/o signals the irq module does not share its pin with any module on this mcu. 7.7.1 irq input pins ( irq) the irq pin provides a maskable external interrupt source. the irq pin contains an internal pullup device. 7.8 registers the irq status and control register (intscr) controls and monitors operation of the irq module. the intscr: shows the state of the irq flag clears the irq latch masks the irq interrupt request controls triggering sensitivity of the irq interrupt pin irqf ?irq flag bit this read-only status bit is set when the irq interrupt is pending. 1 = irq interrupt pending 0 = irq interrupt not pending ack ?irq interrupt request acknowledge bit writing a 1 to this write-only bit clears the irq latch. ack always reads 0. imask ?irq interrupt mask bit writing a 1 to this read/write bit disables the irq interrupt request. 1 = irq interrupt request disabled 0 = irq interrupt request enabled mode ?irq edge/level select bit this read/write bit controls the triggering sensitivity of the irq pin. 1 = irq interrupt request on falling edges and low levels 0 = irq interrupt request on falling edges only bit 7654321bit 0 read: 0000irqf0 imask mode write: ack reset:00000000 = unimplemented figure 7-3. irq status and control register (intscr)
external interrupt (irq) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 84 freescale semiconductor
mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 85 chapter 8 keyboard interrupt module (kbi) 8.1 introduction the keyboard interrupt module (kbi) provides independently maskable external interrupts. the kbi shares its pins with general-purpose input/output (i/o) port pins. see figure 8-2 for port location of these shared pins. 8.2 features features of the keyboard interrupt module include: keyboard interrupt pins with separate keyboard interrupt enable bits and one keyboard interrupt mask programmable edge-only or edge and level interrupt sensitivity edge sensitivity programmable for rising or falling edge level sensitivity programmable for high or low level pullup or pulldown device automatically enabled based on the polarity of edge or level detect exit from low-power modes 8.3 functional description the keyboard interrupt module controls the enabling/disabling of interrupt functions on the kbi pins. these pins can be enabled/disabled independently of each other. figure 8-1. keyboard interrupt block diagram kbi latch keyboard interrupt request ackk internal bus reset kbie0 kbi0 0 1 s kbip0 kbiex kbix 0 1 s kbipx dq ck clr v dd modek imaskk synchronizer keyf to pullup/ to pullup/ pulldown enable pulldown enable vector fetch decoder
keyboard interrupt module (kbi) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 86 freescale semiconductor figure 8-2. block diagram highlighting kbi block and pins all port pins can be configured with internal pullup ptc not available on 16-pin devices (see note in 11.1 introduction) ptd not available on 16-pin or 20-pin devices (see note in 11.1 introduction) pta0/t1ch0/ad0/kbi0 pta1/t1ch1/ad1/kbi1 pta2/ irq/kbi2/t1clk pta3/ rst/kbi3 pta4/osc2/ad2/kbi4 pta5/osc1/ad3/kbi5 4-channel 16-bit timer module keyboard interrupt module single interrupt module periodic wakeup low-voltage inhibit cop module 10-channel 10-bit adc enhanced serial ptb0/spsck/ad4 ptb ddrb m68hc08 cpu pta ddra ptb1/mosi/t2ch1/ad5 ptb2/miso/t2ch0/ad6 ptb3/ ss/t2clk/ad7 ptb4/rxd/t2ch0/ad8 ptb5/txd/t2ch1/ad9 ptb6/t1ch2 ptb7/t1ch3 power supply v dd v ss clock generator communications interface module module serial peripheral interface 16,384 bytes mc68hc908qc16 8192 bytes mc68hc908qc8 512 bytes mc68hc908qc16 384 bytes mc68hc908qc8 break module monitor rom 2-channel 16-bit timer module ptc0 ptc1 ptc2 ptc3 ptc ddrc ptd0 ptd ddrd ptd1 ptd2 ptd3 ptd4 ptd5 ptd6 ptd7 mc68hc908qc4 user ram user flash 4096 bytes 384 bytes mc68hc908qc4
functional description mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 87 8.3.1 keyboard operation writing to the kbiex bits in the keyboard interrupt enable register (kbier) independently enables or disables each kbi pin. the polarity of the keyboard interrupt is controlled using the kbipx bits in the keyboard interrupt polarity register (kbipr). edge-only or edge and level sensitivity is controlled using the modek bit in the keyboard status and control register (kbiscr). enabling a keyboard interrupt pin also enables its internal pullup or pulldown device based on the polarity enabled. on falling edge or low level detection, a pullup device is configured. on rising edge or high level detection, a pulldown device is configured. the keyboard interrupt latch is set when one or more enabled keyboard interrupt inputs are asserted. if the keyboard interrupt sensitivity is edge-only, for kbipx = 0, a falling (for kbipx = 1, a rising) edge on a keyboard interrupt input does not latch an interrupt request if another enabled keyboard pin is already asserted. to prevent losing an interrupt request on one input because another input remains asserted, software can disable the latter input while it is asserted. if the keyboard interrupt is edge and level sensitive, an interrupt request is present as long as any enabled keyboard interrupt input is asserted. 8.3.1.1 modek = 1 if the modek bit is set, the keyboard interrupt inputs are both edge and level sensitive. the kbipx bit will determine whether a edge sensitive pin detects rising or falling edges and on level sensitive pins whether the pin detects low or high levels. with modek set, both of the following actions must occur to clear a keyboard interrupt request: return of all enabled keyboard interrupt inputs to a deasserted level. as long as any enabled keyboard interrupt pin is asserted, the keyboard interrupt remains active. vector fetch or software clear. a kbi vector fetch generates an interrupt acknowledge signal to clear the kbi latch. software generates the interrupt acknowledge signal by writing a 1 to ackk in kbscr. the ackk bit is useful in applications that poll the keyboard interrupt inputs and require software to clear the kbi latch. writing to ackk prior to leaving an interrupt service routine can also prevent spurious interrupts due to noise. setting ackk does not affect subsequent transitions on the keyboard interrupt inputs. an edge detect that occurs after writing to ackk latches another interrupt request. if the keyboard interrupt mask bit, imaskk, is clear, the cpu loads the program counter with the kbi vector address. the kbi vector fetch or software clear and the return of all enabled keyboard interrupt pins to a deasserted level may occur in any order. reset clears the keyboard interrupt request and the modek bit, clearing the interrupt request even if a keyboard interrupt input stays asserted. 8.3.1.2 modek = 0 if the modek bit is clear, the keyboard interrupt inputs are edge sensitive. the kbipx bit will determine whether an edge sensitive pin detects rising or falling edges. a kbi vector fetch or software clear immediately clears the kbi latch.
keyboard interrupt module (kbi) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 88 freescale semiconductor the keyboard flag bit (keyf) in kbscr can be read to check for pending interrupts. the keyf bit is not affected by imaskk, which makes it useful in applications where polling is preferred. note setting a keyboard interrupt enable bit (kbiex) forces the corresponding keyboard interrupt pin to be an input, overriding the data direction register. however, the data direction register bit must be a 0 for software to read the pin. 8.3.2 keyboard initialization when a keyboard interrupt pin is enabled, it takes time for the internal pullup or pulldown device to pull the pin to its deasserted level. therefore a false interrupt can occur as soon as the pin is enabled. to prevent a false interrupt on keyboard initialization: 1. mask keyboard interrupts by setting imaskk in kbscr. 2. enable the kbi polarity by setting the appropriate kbipx bits in kbipr. 3. enable the kbi pins by setting the appropriate kbiex bits in kbier. 4. write to ackk in kbscr to clear any false interrupts. 5. clear imaskk. an interrupt signal on an edge sensitive pin can be acknowledged immediately after enabling the pin. an interrupt signal on an edge and level sensitive pin must be acknowledged after a delay that depends on the external load. 8.4 interrupts the following kbi source can generate interrupt requests: keyboard flag (keyf) ?the keyf bit is set when any enabled kbi pin is asserted based on the kbi mode and pin polarity. the keyboard interrupt mask bit, imaskk, is used to enable or disable kbi interrupt requests. 8.5 low-power modes the wait and stop instructions put the mcu in low power-consumption standby modes. 8.5.1 wait mode the kbi module remains active in wait mode. clearing imaskk in kbscr enables keyboard interrupt requests to bring the mcu out of wait mode. 8.5.2 stop mode the kbi module remains active in stop mode. clearing imaskk in kbscr enables keyboard interrupt requests to bring the mcu out of stop mode.
kbi during break interrupts mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 89 8.6 kbi during break interrupts the system integration module (sim) controls whether status bits in other modules can be cleared during the break state. the bcfe bit in the break flag control register (bfcr) enables software to clear status bits during the break state. see bfcr in the sim section of this data sheet. to allow software to clear status bits during a break interrupt, write a 1 to bcfe. if a status bit is cleared during the break state, it remains cleared when the mcu exits the break state. to protect status bits during the break state, write a 0 to bcfe. with bcfe cleared (its default state), software can read and write registers during the break state without affecting status bits. some status bits have a two-step read/write clearing procedure. if software does the first step on such a bit before the break, the bit cannot change during the break state as long as bcfe is cleared. after the break, doing the second step clears the status bit. 8.7 i/o signals the kbi module can share its pins with the general-purpose i/o pins. see figure 8-2 for the port pins that are shared. 8.7.1 kbi input pins (kbi7:kbi0) each kbi pin is independently programmable as an external interrupt source. kbi pin polarity can be controlled independently. e ach kbi pin when enabled will automatically configure the appropriate pullup/pulldown device based on polarity. 8.8 registers the following registers control and monitor operation of the kbi module: kbscr (keyboard interrupt status and control register) kbier (keyboard interrupt enable register) kbipr (keyboard interrupt polarity register) 8.8.1 keyboard status and control register (kbscr) features of the kbscr: flags keyboard interrupt requests acknowledges keyboard interrupt requests masks keyboard interrupt requests controls keyboard interrupt triggering sensitivity
keyboard interrupt module (kbi) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 90 freescale semiconductor keyf ?keyboard flag bit this read-only bit is set when a keyboard interrupt is pending. 1 = keyboard interrupt pending 0 = no keyboard interrupt pending ackk ?keyboard acknowledge bit writing a 1 to this write-only bit clears the kbi request. ackk always reads 0. imaskk?keyboard interrupt mask bit writing a 1 to this read/write bit prevents the output of the kbi latch from generating interrupt requests. 1 = keyboard interrupt requests disabled 0 = keyboard interrupt requests enabled modek ?keyboard triggering sensitivity bit this read/write bit controls the triggering sensitivity of the keyboard interrupt pins. 1 = keyboard interrupt requests on edge and level 0 = keyboard interrupt requests on edge only 8.8.2 keyboard interrupt enable register (kbier) kbier enables or disables each keyboard interrupt pin. kbie5?bie0 ?keyboard interrupt enable bits each of these read/write bits enables the corresponding keyboard interrupt pin to latch kbi interrupt requests. 1 = kbix pin enabled as keyboard interrupt pin 0 = kbix pin not enabled as keyboard interrupt pin r ?reserved bit this reserved bit should always be written to a 0 and will read 0. bit 7654321bit 0 read: 0000 keyf 0 imaskk modek write: ackk reset:00000000 = unimplemented figure 8-3. keyboard status and control register (kbscr) bit 7654321bit 0 read: 0 r kbie5 kbie4 kbie3 kbie2 kbie1 kbie0 write: reset:00000000 = unimplemented figure 8-4. keyboard interrupt enable register (kbier)
registers mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 91 8.8.3 keyboard interrupt polarity register (kbipr) kbipr determines the polarity of the enabled keyboard interrupt pin and enables the appropriate pullup or pulldown device. kbip5?bip0 ?keyboard interrupt polarity bits each of these read/write bits enables the polarity of the keyboard interrupt detection. 1 = keyboard polarity is high level and/or rising edge 0 = keyboard polarity is low level and/or falling edge bit 7654321bit 0 read: 0 0 kbip5 kbip4 kbip3 kbip2 kbip1 kbip0 write: reset:00000000 = unimplemented figure 8-5. keyboard interrupt polarity register (kbipr)
keyboard interrupt module (kbi) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 92 freescale semiconductor
mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 93 chapter 9 low-voltage inhibit (lvi) 9.1 introduction the low-voltage inhibit (lvi) module is provided as a system protection mechanism to prevent the mcu from operating below a certain operating supply voltage level. the module has several configuration options to allow functionality to be tailored to different system level demands. the configuration registers (see chapter 4 configuration registers (config1 and config2) ) contain control bits for this module. 9.2 features features of the lvi module include: programmable lvi reset selectable lvi trip voltage programmable stop mode operation 9.3 functional description figure 9-1 shows the structure of the lvi module. lvistop, lvipwrd, lvitrip, and lvirstd are user selectable options found in the configuration register. figure 9-1. lvi module block diagram low v dd detector lvipwrd stop instruction lvistop lvi reset lviout 0 if v dd > v tripr 1 if v dd v tripf from configuration register v dd lvirstd lvitrip from configuration register from configuration register from configuration register
low-voltage inhibit (lvi) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 94 freescale semiconductor the lvi module contains a bandgap reference circuit and comparator. when the lvitrip bit is cleared, the default state at power-on reset, v tripf is configured for the lower v dd operating range. the actual trip points are specified in 19.5 5-v dc electrical characteristics and 19.8 3.3-v dc electrical characteristics. because the default lvi trip point after power-on reset is configured for low voltage operation, a system requiring high voltage lvi operation must set the lvitrip bit during system initialization. v dd must be above the lvi trip rising voltage, v tripr , for the high voltage operating range or the mcu will immediately go into lvi reset. after an lvi reset occurs, the mcu remains in reset until v dd rises above v tripr . see chapter 14 system integration module (sim) for the reset recovery sequence. the output of the comparator controls the state of the lviout flag in the lvi status register (lvisr) and can be used for polling lvi operation when the lvi reset is disabled. the lvi is enabled out of reset. the following bits located in the configuration register can alter the default conditions. setting the lvi power disable bit, lvipwrd, disables the lvi. setting the lvi reset disable bit, lvirstd, prevents the lvi module from generating a reset. setting the lvi enable in stop mode bit, lvistop, enables the lvi to operate in stop mode. setting the lvi trip point bit, lvitrip, configures the trip point voltage (v tripf ) for the higher v dd operating range. 9.3.1 polled lvi operation in applications that can operate at v dd levels below the v tripf level, software can monitor v dd by polling the lviout bit. in the configuration register, lvipwrd must be cleared to enable the lvi module, and lvirstd must be set to disable lvi resets. 9.3.2 forced reset operation in applications that require v dd to remain above the v tripf level, enabling lvi resets allows the lvi module to reset the mcu when v dd falls below the v tripf level. in the configuration register, lvipwrd and lvirstd must be cleared to enable the lvi module and to enable lvi resets. 9.3.3 lvi hysteresis the lvi has hysteresis to maintain a stable operating condition. after the lvi has triggered (by having v dd fall below v tripf ), the mcu will remain in reset until v dd rises above the rising trip point voltage, v tripr . this prevents a condition in which the mcu is continually entering and exiting reset if v dd is approximately equal to v tripf . v tripr is greater than v tripf by the typical hysteresis voltage, v hys . 9.3.4 lvi trip selection lvitrip in the configuration register selects the lvi protection range. the default setting out of reset is for the low voltage range. because lvitrip is in a write-once configuration register, the protection range cannot be changed after initialization. note the mcu is guaranteed to operate at a minimum supply voltage. the trip point (v tripf ) may be lower than this. see the electrical characteristics section for the actual trip point voltages.
lvi interrupts mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 95 9.4 lvi interrupts the lvi module does not generate interrupt requests. 9.5 low-power modes the stop and wait instructions put the mcu in low power-consumption standby modes. 9.5.1 wait mode if enabled, the lvi module remains active in wait mode. if enabled to generate resets, the lvi module can generate a reset and bring the mcu out of wait mode. 9.5.2 stop mode if the lvipwrd bit in the configuration register is cleared and the lvistop bit in the configuration register is set, the lvi module remains active. if enabled to generate resets, the lvi module can generate a reset and bring the mcu out of stop mode. 9.6 registers the lvi status register (lvisr) contains a status bit that is useful when the lvi is enabled and lvi reset is disabled. lviout ?lvi output bit this read-only flag becomes set when the v dd voltage falls below the v tripf trip voltage and is cleared when v dd voltage rises above v tripr . (see table 9-1 .) bit 7654321bit 0 read: lviout 000000r write: reset:00000000 = unimplemented r = reserved figure 9-2. lvi status register (lvisr) table 9-1. lviout bit indication v dd lviout v dd > v tripr 0 v dd < v tripf 1 v tripf < v dd < v tripr previous value
low-voltage inhibit (lvi) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 96 freescale semiconductor
mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 97 chapter 10 oscillator mode (osc) 10.1 introduction the oscillator (osc) module is used to provide a stable clock source for the mcu system and bus. the osc shares its pins with general-purpose input/output (i/o) port pins. see figure 10-1 for port location of these shared pins. the osc2en bit is located in the port a pull enable register (ptapuen) on this mcu. see chapter 11 input/output ports (ports) for information on ptapuen register. 10.2 features the bus clock frequency is one fourth of any of these clock source options: 1. internal oscillator: an internally generated, fixed frequency clock, trimmable to 0.4%. there are four choices for the internal oscillator, 25.6 mhz, 12.8 mhz, 8 mhz, or 4 mhz. the 4-mhz internal oscillator is the default option out of reset. 2. external oscillator: an external clock that can be driven directly into osc1. 3. external rc: a built-in oscillator module (rc oscillator) that requires an external r connection only. the capacitor is internal to the chip. 4. external crystal: a built-in xtal oscillator that requires an external crystal or ceramic-resonator. there are three crystal frequency ranges supported, 8?2 mhz, 1? mhz, and 32?00 khz. 10.3 functional description the oscillator contains these major subsystems: internal oscillator circuit internal or external clock switch control external clock circuit external crystal circuit external rc clock circuit 10.3.1 internal signal definitions the following signals and clocks are used in the functional description and figures of the osc module. 10.3.1.1 oscillator enable signal (simoscen) the simoscen signal comes from the system integration module (sim) and disables the xtal oscillator circuit, the rc oscillator, or the internal oscillator in stop mode. osceninstop in the configuration register can be used to override this signal.
oscillator mode (osc) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 98 freescale semiconductor figure 10-1. block diagram highlighting osc block and pins all port pins can be configured with internal pullup ptc not available on 16-pin devices (see note in 11.1 introduction) ptd not available on 16-pin or 20-pin devices (see note in 11.1 introduction) pta0/t1ch0/ad0/kbi0 pta1/t1ch1/ad1/kbi1 pta2/ irq/kbi2/t1clk pta3/ rst/kbi3 pta4/osc2/ad2/kbi4 pta5/osc1/ad3/kbi5 4-channel 16-bit timer module keyboard interrupt module single interrupt module periodic wakeup low-voltage inhibit cop module 10-channel 10-bit adc enhanced serial ptb0/spsck/ad4 ptb ddrb m68hc08 cpu pta ddra ptb1/mosi/t2ch1/ad5 ptb2/miso/t2ch0/ad6 ptb3/ ss/t2clk/ad7 ptb4/rxd/t2ch0/ad8 ptb5/txd/t2ch1/ad9 ptb6/t1ch2 ptb7/t1ch3 power supply v dd v ss clock generator communications interface module module serial peripheral interface 16,384 bytes mc68hc908qc16 8192 bytes mc68hc908qc8 512 bytes mc68hc908qc16 384 bytes mc68hc908qc8 break module monitor rom 2-channel 16-bit timer module ptc0 ptc1 ptc2 ptc3 ptc ddrc ptd0 ptd ddrd ptd1 ptd2 ptd3 ptd4 ptd5 ptd6 ptd7 mc68hc908qc4 user ram user flash 4096 bytes 384 bytes mc68hc908qc4
functional description mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 99 10.3.1.2 xtal oscillator clock (xtalclk) xtalclk is the xtal oscillator output signal. it runs at the full speed of the crystal (f xclk ) and comes directly from the crystal oscillator circuit. figure 10-2 shows only the logical relation of xtalclk to osc1 and osc2 and may not represent the actual circuitry. the duty cycle of xtalclk is unknown and may depend on the crystal and other external factors. the frequency of xtalclk can be unstable at start up. 10.3.1.3 rc oscillator clock (rcclk) rcclk is the rc oscillator output signal. its frequency is directly proportional to the time constant of the external r (r ext ) and internal c. figure 10-3 shows only the logical relation of rcclk to osc1 and may not represent the actual circuitry. 10.3.1.4 internal oscillator clock (intclk) intclk is the internal oscillator output signal. intclk is software selectable to be nominally 25.6 mhz, 12.8 mhz, 8.0 mhz, or 4.0 mhz. intclk can be digitally adjusted using the oscillator trimming feature of the osctrim register (see 10.3.2.1 internal oscillator trimming). 10.3.1.5 bus clock times 4 (busclkx4) busclkx4 is the same frequency as the input clock (xtalclk, rcclk, or intclk). this signal is driven to the sim module and is used during recovery from reset and stop and is the clock source for the cop module. 10.3.1.6 bus clock times 2 (busclkx2) the frequency of this signal is equal to half of the busclkx4. this signal is driven to the sim for generation of the bus clocks used by the cpu and other modules on the mcu. busclkx2 will be divided by two in the sim. the internal bus frequency is one fourth of the xtalclk, rcclk, or intclk frequency. 10.3.2 internal oscillator the internal oscillator circuit is designed for use with no external components to provide a clock source with a tolerance of less than 25%untrimmed. an 8-bit register (osctrim) allows the digital adjustment to a tolerance of acc int . see the oscillator characteristics in the electrical section of this data sheet. the internal oscillator is capable of generating clocks of 25.6 mhz, 12.8 mhz, 8.0 mhz, or 4.0 mhz (intclk) resulting in a bus frequency (intclk divided by 4) of 6.4 mhz, 3.2 mhz, 2.0 mhz, or 1.0 mhz respectively. the bus clock is software selectable and defaults to the 1.0-mhz bus out of reset. users can increase the bus frequency based on the voltage range of their application. figure 10-3 shows how busclkx4 is derived from intclk and osc2 can output busclkx4 by setting osc2en. 10.3.2.1 internal oscillator trimming osctrim allows a clock period adjustment of +127 and ?28 steps. increasing the osctrim value increases the clock period, which decreases the clock frequency. trimming allows the internal clock frequency to be fine tuned to the target frequency. all devices are factory programmed with a trim value that is stored in flash memory at location $ffc0. this trim value is not automatically loaded into osctrim register. user software must copy the trim value
oscillator mode (osc) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 100 freescale semiconductor from $ffc0 into osctrim if needed. the factory trim value provides the accuracy required for communication using force monitor mode. trimming the device in the user application board will provide the most accurate trim value. see oscillator characteristics in the electrical chapter of this data book for additional information on factory trim. 10.3.2.2 internal to external clock switching when external clock source (external osc, rc, or xtal) is desired, the user must perform the following steps: 1. for external crystal circuits only, configure oscopt[1:0] to external crystal. to help precharge an external crystal oscillator, momentarily configure osc2 as an output and drive it high for several cycles. this can help the crystal circuit start more robustly. 2. configure oscopt[1:0] and ecfs[1:0] according to 10.8.1 oscillator status and control register . the oscillator module control logic will then enable osc1 as an external clock input and, if the external crystal option is selected, osc2 will also be enabled as the clock output. if rc oscillator option is selected, enabling the osc2 output may change the bus frequency. 3. create a software delay to provide the stabilization time required for the selected clock source (crystal, resonator, rc). a good rule of thumb for crystal oscillators is to wait 4096 cycles of the crystal frequency; i.e., for a 4-mhz crystal, wait approximately 1 ms. 4. after the stabilization delay has elapsed, set ecgon. after ecgon set is detected, the osc module checks for oscillator activity by waiting two external clock rising edges. the osc module then switches to the external clock. logic provides a coherent transition. the osc module first sets ecgst and then stops the internal oscillator. 10.3.2.3 external to internal clock switching after following the procedures to switch to an external clock source, it is possible to go back to the internal source. by clearing the oscopt[1:0] bits and clearing the ecgon bit, the external circuit will be disengaged. the bus clock will be derived from the selected internal clock source based on the icfs[1:0] bits. 10.3.3 external oscillator the external oscillator option is designed for use when a clock signal is available in the application to provide a clock source to the mcu. the osc1 pin is enabled as an input by the oscillator module. the clock signal is used directly to create busclkx4 and also divided by two to create busclkx2. in this configuration, the osc2 pin cannot output busclkx4. the osc2en bit will be forced clear to enable alternative functions on the pin. 10.3.4 xtal oscillator the xtal oscillator circuit is designed for use with an external crystal or ceramic resonator to provide an accurate clock source. in this configuration, the osc2 pin is dedicated to the external crystal circuit. the osc2en bit has no effect when this clock mode is selected. in its typical configuration, the xtal oscillator is connected in a pierce oscillator configuration, as shown in figure 10-2 . this figure shows only the logical representation of the internal components and may not represent actual circuitry.
functional description mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 101 the oscillator configuration uses five components: crystal, x 1 fixed capacitor, c 1 tuning capacitor, c 2 (can also be a fixed capacitor) feedback resistor, r b series resistor, r s (optional) note the series resistor (r s ) is included in the diagram to follow strict pierce oscillator guidelines and may not be required for all ranges of operation, especially with high frequency crystals. refer to the oscillator characteristics table in the electricals section for more information. figure 10-2. xtal oscillator external connections 10.3.5 rc oscillator the rc oscillator circuit is designed for use with an external resistor (r ext ) to provide a clock source with a tolerance within 25% of the expected frequency. see figure 10-3 . the capacitor (c) for the rc oscillator is internal to the mcu. the r ext value must have a tolerance of 1% or less to minimize its effect on the frequency. in this configuration, the osc2 pin can be used as general-purpose input/output (i/o) port pins or other alternative pin function. the osc2en bit can be set to enable the osc2 output function on the pin. enabling the osc2 output can affect the external rc oscillator frequency, f rcclk . c 1 c 2 xtalclk r b x 1 r s mcu osc2 osc1 2 busclkx2 busclkx4 see the electrical section for details. simoscen (internal signal) or osceninstop (bit located in configuration register))
oscillator mode (osc) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 102 freescale semiconductor figure 10-3. rc oscillator external connections 10.4 interrupts there are no interrupts associated with the osc module. 10.5 low-power modes the wait and stop instructions put the mcu in low power-consumption standby modes. 10.5.1 wait mode the osc module remains active in wait mode. 10.5.2 stop mode the osc module can be configured to remain active in stop mode by setting osceninstop located in a configuration register. 10.6 osc during break interrupts there are no status flags associated with the osc module. the system integration module (sim) controls whether status bits in other modules can be cleared during the break state. the bcfe bit in the break flag control register (bfcr) enables software to clear status bits during the break state. see bfcr in the sim section of this data sheet. to allow software to clear status bits during a break interrupt, write a 1 to bcfe. if a status bit is cleared during the break state, it remains cleared when the mcu exits the break state. mcu r ext osc1 external rc oscillator en rcclk 2 busclkx2 busclkx4 v dd 1 0 osc2en osc2- available for alternative pin function see the electricals section for component value. 0 1 intclk oscopt = external rc selected simoscen (internal signal) or osceninstop (bit located in configuration register)) alternative pin function
i/o signals mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 103 to protect status bits during the break state, write a 0 to bcfe. with bcfe cleared (its default state), software can read and write registers during the break state without affecting status bits. some status bits have a two-step read/write clearing procedure. if software does the first step on such a bit before the break, the bit cannot change during the break state as long as bcfe is cleared. after the break, doing the second step clears the status bit. 10.7 i/o signals the osc shares its pins with general-purpose input/output (i/o) port pins. see figure 10-1 for port location of these shared pins. 10.7.1 oscillator input pin (osc1) the osc1 pin is an input to the crystal oscillator amplifier, an input to the rc oscillator circuit, or an input from an external clock source. when the osc is configured for internal oscillator, the osc1 pin can be used as a general-purpose input/output (i/o) port pin or other alternative pin function. 10.7.2 oscillator output pin (osc2) for the xtal oscillator option, the osc2 pin is the output of the crystal oscillator amplifier. when the osc is configured for internal oscillator, external clock, or rc, the osc2 pin can be used as a general-purpose i/o port pin or other alternative pin function. when the oscillator is configured for internal or rc, the osc2 pin can be used to output busclkx4. 10.8 registers the oscillator module contains two registers: oscillator status and control register (oscsc) oscillator trim register (osctrim) 10.8.1 oscillator status and control register the oscillator status and control register (oscsc) contains the bits for switching between internal and external clock sources. if the application uses an external crystal, bits in this register are used to select the crystal oscillator amplifier necessary for the desired crystal. while running off the internal clock source, the user can use bits in this register to select the internal clock source frequency. table 10-1. osc2 pin function option osc2 pin function xtal oscillator inverting osc1 external clock general-purpose i/o or alternative pin function internal oscillator or rc oscillator controlled by osc2en bit osc2en = 0: general-purpose i/o or alternative pin function osc2en = 1: busclkx4 output
oscillator mode (osc) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 104 freescale semiconductor oscopt1:oscopt0 ?osc option bits these read/write bits allow the user to change the clock source for the mcu. the default reset condition has the bus clock being derived from the internal oscillator. see 10.3.2.2 internal to external clock switching for information on changing clock sources. icfs1:icfs0 ?internal clock frequency select bits these read/write bits enable the frequency to be increased for applications requiring a faster bus clock when running off the internal oscillator. the wait instruction has no effect on the oscillator logic. busclkx2 and busclkx4 continue to drive to the sim module. ecfs1:ecfs0 ?external crystal frequency select bits these read/write bits enable the specific amplifier for the crystal frequency range. refer to oscillator characteristics table in the electricals section for information on maximum external clock frequency versus supply voltage. ecgon ?external clock generator on bit this read/write bit enables the osc1 pin as the clock input to the mcu, so that the switching process can be initiated. this bit is cleared by reset. this bit is ignored in monitor mode with the internal oscillator bypassed. 1 = external clock enabled 0 = external clock disabled bit 7654321bit 0 read: oscopt1 oscopt0 icfs1 icfs0 ecfs1 ecfs0 ecgon ecgst write: reset:0 0000000 = unimplemented figure 10-4. oscillator status and control register (oscsc) oscopt1 oscopt0 oscillator modes 0 0 internal oscillator (frequency selected using icfsx bits) 0 1 external oscillator clock 1 0 external rc 1 1 external crystal (range selected using ecfsx bits) icfs1 icfs0 internal clock frequency 0 0 4.0 mhz ?default reset condition 0 1 8.0 mhz 1 0 12.8 mhz 1 1 25.6 mhz ecfs1 ecfs0 external crystal frequency 0 0 8 mhz ?32 mhz 0 1 1 mhz ?8 mhz 1 0 32 khz ?100 khz 1 1 reserved
registers mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 105 ecgst ?external clock status bit this read-only bit indicates whether an external clock source is engaged to drive the system clock. 1 = an external clock source engaged 0 = an external clock source disengaged 10.8.2 oscillator trim register (osctrim) trim7?rim0 ?internal oscillator trim factor bits these read/write bits change the internal capacitance used by the internal oscillator. by measuring the period of the internal clock and adjusting this factor accordingly, the frequency of the internal clock can be fine tuned. increasing (decreasing) this factor by one increases (decreases) the period by approximately 0.2% of the untrimmed oscillator period. the oscillator period is based on the oscillator frequency selected by the icfs bits in oscsc. bit 7654321bit 0 read: trim7 trim6 trim5 trim4 trim3 trim2 trim1 trim0 write: reset:10000000 figure 10-5. oscillator trim register (osctrim)
oscillator mode (osc) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 106 freescale semiconductor
mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 107 chapter 11 input/output ports (ports) 11.1 introduction the mc68hc908qc16 has up to 24 bidirectional input-output (i/o) pins and two input only pins depending on the package selection. all i/o pins are programmable as inputs and outputs. 11.2 unused pin termination input pins and i/o port pins that are not used in the application must be terminated. this prevents excess current caused by floating inputs, and enhances immunity during noise or transient events. termination methods include: 1. configuring unused pins as outputs and driving high or low; 2. configuring unused pins as inputs and enabling internal pull-ups; 3. configuring unused pins as inputs and using external pull-up or pull-down resistors. never connect unused pins directly to v dd or v ss . since some general-purpose i/o pins are not available on all packages, these pins must be terminated as well. either method 1 or 2 above are appropriate. 11.3 port a port a is an 6-bit special function port that shares all six of its pins with the keyboard interrupt (kbi) module (see chapter 8 keyboard interrupt module (kbi)). each port a pin also has a software configurable pullup device if the corresponding port pin is configured as an input port. note pta2 is input only. pta2 has a high voltage detector to enable entry into special modes. do not exceed the v dd level on this pin in normal operation. when the irq function is enabled in the configuration register 2 (config2), bit 2 of the port a data register (pta) will always read a 0. in this case, the bih and bil instructions can be used to read the logic level on the pta2 pin. when the irq function is disabled, these instructions will behave as if the pta2 pin is a logic 1. however, reading bit 2 of pta will read the actual logic level on the pin.
input/output ports (ports) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 108 freescale semiconductor 11.3.1 port a data register the port a data register (pta) contains a data latch for each of the six port a pins. pta5?ta3, pta1, pta0 ?port a data bits these read/write bits are software programmable. data direction of each port a pin is under the control of the corresponding bit in data direction register a. reset has no effect on port a data. pta2 ?port a data bit this read-only bit reads the state of the pta2 pin. kbi[5:0] ?port a keyboard interrupts the keyboard interrupt enable bits, kbie5?bie0, in the keyboard interrupt control enable register (kbier) enable the port a pins as external interrupt pins (see chapter 8 keyboard interrupt module (kbi) ). 11.3.2 data direction register a data direction register a (ddra) determines whether each port a pin is an input or an output. writing a 1 to a ddra bit enables the output buffer for the corresponding port a pin; a 0 disables the output buffer. ddra[5:0] ?data direction register a bits these read/write bits control port a data direction. reset clears ddra[5:0], configuring all port a pins as inputs. 1 = corresponding port a pin configured as output 0 = corresponding port a pin configured as input note avoid glitches on port a pins by writing to the port a data register before changing data direction register a bits from 0 to 1. bit 7654321bit 0 read: r r pta5 pta4 pta3 pta2 pta1 pta0 write: reset: unaffected by reset additional functions: kbi5 kbi4 kbi3 kbi2 kbi1 kbi0 r = reserved = unimplemented figure 11-1. port a data register (pta) bit 7 6 5 4 3 2 1 bit 0 read: r r ddra5 ddra4 ddra3 0 ddra1 ddra0 write: reset:00000000 r = reserved = unimplemented figure 11-2. data direction register a (ddra)
port a mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 109 figure 11-3 shows the port a i/o logic. figure 11-3. port a i/o circuit note figure 11-3 does not apply to pta2. when ddrax is a 1, reading address $0000 reads the ptax data latch. when ddrax is a 0, reading address $0000 reads the voltage level on the pin. the data latch can always be written, regardless of the state of its data direction bit. 11.3.3 port a input pullup enable register the port a input pullup enable register (ptapue) contains a software configurable pullup device for each if the six port a pins. each bit is individually configurable and requires the corresponding data direction register, ddrax, to be configured as input. each pullup device is automatically and dynamically disabled when its corresponding ddrax bit is configured as output. osc2en ?enable pta4 on osc2 pin this read/write bit configures the osc2 pin function when internal oscillator or rc oscillator option is selected. this bit has no effect for the xtal or external oscillator options. 1 = osc2 pin outputs the internal or rc oscillator clock (busclkx4) 0 = osc2 pin configured for pta4 i/o, having all the interrupt and pullup functions ptapue[5:0] ?port a input pullup enable bits these read/write bits are software programmable to enable pullup devices on port a pins. 1 = corresponding port a pin configured to have internal pull if its ddra bit is set to 0 0 = pullup device is disconnected on the corresponding port a pin regardless of the state of its ddra bit bit 7654321bit 0 read: osc2en ptapue5 ptapue4 ptapue3 ptapue2 ptapue1 ptapue0 write: reset:00000000 = unimplemented figure 11-4. port a input pullup enable register (ptapue) read ddra ($0004) write ddra ($0004) reset write pta ($0000) read pta ($0000) ptax ddrax ptax internal data bus pullup ptapuex to keyboard interrupt circuit
input/output ports (ports) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 110 freescale semiconductor table 11-1 summarizes the operation of the port a pins. 11.4 port b port b is an 8-bit general purpose i/o port. each port b pin can be configured to have an internal pullup when used as an input port pin. 11.4.1 port b data register the port b data register (ptb) contains a data latch for each of the eight port b pins. ptb[7:0] ?port b data bits these read/write bits are software programmable. data direction of each port b pin is under the control of the corresponding bit in data direction register b. reset has no effect on port b data. 11.4.2 data direction register b data direction register b (ddrb) determines whether each port b pin is an input or an output. writing a 1 to a ddrb bit enables the output buffer for the corresponding port b pin; a 0 disables the output buffer. ddrb[7:0] ?data direction register b bits these read/write bits control port b data direction. reset clears ddrb[7:0], configuring all port b pins as inputs. 1 = corresponding port b pin configured as output 0 = corresponding port b pin configured as input table 11-1. port a pin functions ptapue bit ddra bit pta bit i/o pin mode accesses to ddra accesses to pta read/write read write 10 x (1) 1. x = don? care input, v dd (2) 2. i/o pin pulled to v dd by internal pullup. ddra5?dra0 pin pta5?ta0 (3) 3. writing affects data register, but does not affect input. 00x input, hi-z (4) 4. hi-z = high impedance ddra5?dra0 pin pta5?ta0 (3) x 1 x output ddra5?dra0 pta5?ta0 pta5?ta0 (5) 5. output does not apply to pta2 bit 7654321bit 0 read: ptb7 ptb6 ptb5 ptb4 ptb3 ptb2 ptb1 ptb0 write: reset: unaffected by reset figure 11-5. port b data register (ptb) bit 7 6 5 4 3 2 1 bit 0 read: ddrb7 ddrb6 ddrb5 ddrb4 ddrb3 ddrb2 ddrb1 ddrb0 write: reset:00000000 figure 11-6. data direction register b (ddrb)
port b mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 111 note avoid glitches on port b pins by writing to the port b data register before changing data direction register b bits from 0 to 1. figure 11-7 shows the port b i/o logic. figure 11-7. port b i/o circuit when ddrbx is a 1, reading address $0001 reads the ptbx data latch. when ddrbx is a 0, reading address $0001 reads the voltage level on the pin. the data latch can always be written, regardless of the state of its data direction bit. 11.4.3 port b input pullup enable register the port b input pullup enable register (ptbpue) contains a software configurable pullup device for each of the eight port b pins. each bit is individually configurable and requires the corresponding data direction register, ddrbx, be configured as input. each pullup device is automatically and dynamically disabled when its corresponding ddrbx bit is configured as output. ptbpue[7:0] ?port b input pullup enable bits these read/write bits are software programmable to enable pullup devices on port b pins 1 = corresponding port b pin configured to have internal pull if its ddrb bit is set to 0 0 = pullup device is disconnected on the corresponding port b pin regardless of the state of its ddrb bit. table 11-2 summarizes the operation of the port b pins. bit 7 6 5 4 3 2 1 bit 0 read: ptbpue7 ptbpue6 ptbpue5 ptbpue4 ptbpue3 ptbpue2 ptbpue2 ptbpue0 write: reset:00000000 figure 11-8. port b input pullup enable register (ptbpue) read ddrb ($0005) write ddrb ($0005) reset write ptb ($0001) read ptb ($0001) ptbx ddrbx ptbx internal data bus pullup ptbpuex
input/output ports (ports) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 112 freescale semiconductor 11.5 port c port c is an 4-bit general purpose port. ptc3 is an input only port pin, while ptc2?tc0 can be configured for either input or output. each port c pin can be configured to have an internal pullup when used as an input pin. note ptc3 has a high voltage detector to enable entry into special modes. do not exceed the v dd level on this pin in normal operation. 11.5.1 port c data register the port c data register (ptc) contains a data latch for each of the port c pins. ptc[2:0] ?port c data bits these read/write bits are software programmable. data direction of each port c pin is under the control of the corresponding bit in data direction register c. reset has no effect on port c data. ptc3 ?port c data bit this read-only bit reads the state of the ptc3 pin. table 11-2. port b pin functions ptbpue bit ddrb bit ptb bit i/o pin mode accesses to ddrb accesses to ptb read/write read write 10 x (1) 1. x = don? care input, v dd (2) 2. i/o pin pulled to v dd by internal pullup. ddrb7?drb0 pin ptb7?tb0 (3) 3. writing affects data register, but does not affect input. 00x input, hi-z (4) 4. hi-z = high impedance ddrb7?drb0 pin ptb7?tb0 (3) x 1 x output ddrb7?drb0 ptb7?tb0 ptb7?tb0 bit 7654321bit 0 read: 0 0 0 0 ptc3 ptc2 ptc1 ptc0 write: reset: unaffected by reset = unimplemented figure 11-9. port c data register (ptc)
port c mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 113 11.5.2 data direction register c data direction register c (ddrc) determines whether each port c pin is an input or an output. writing a 1 to a ddrc bit enables the output buffer for the corresponding port c pin; a 0 disables the output buffer. ddrc[2:0] ?data direction register c bits these read/write bits control port c data direction. reset clears ddrc[2:0], configuring all port c pins as inputs. 1 = corresponding port c pin configured as output 0 = corresponding port c pin configured as input note avoid glitches on port c pins by writing to the port c data register before changing data direction register c bits from 0 to 1. figure 11-11 shows the port c i/o logic. figure 11-11. port c i/o circuit note figure 11-11 does not apply to ptc3. when ddrcx is a 1, reading address $0002 reads the ptcx data latch. when ddrcx is a 0, reading address $0002 reads the voltage level on the pin. the data latch can always be written, regardless of the state of its data direction bit. bit 7 6 5 4 3 2 1 bit 0 read: 0 0 0 0 0 ddrc2 ddrc1 ddrc0 write: reset:00000000 = unimplemented figure 11-10. data direction register c (ddrc) read ddrc ($0006) write ddrc ($0006) reset write ptc ($0002) read ptc ($0002) ptcx ddrcx ptcx internal data bus pullup ptcpuex
input/output ports (ports) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 114 freescale semiconductor 11.5.3 port c input pullup enable register the port c input pullup enable register (ptcpue) contains a software configurable pullup device for each of the four port c pins. each bit is individually configurable and requires the corresponding data direction register, ddrcx, be configured as input. each pullup device is automatically and dynamically disabled when its corresponding ddrcx bit is configured as output. ptcpue[3:0] ?port c input pullup enable bits these read/write bits are software programmable to enable pullup devices on port c pins 1 = corresponding port c pin configured to have internal pull if its ddrc bit is set to 0 0 = pullup device is disconnected on the corresponding port c pin regardless of the state of its ddrc bit. table 11-3 summarizes the operation of the port c pins. 11.6 port d port d is an 8-bit general purpose i/o port. each port d pin can be configured to have an internal pullup when used as an input port pin. 11.6.1 port d data register the port d data register (ptd) contains a data latch for each of the eight port d pins. bit 7 6 5 4 3 2 1 bit 0 read:0000 ptcpue3 ptcpue2 ptcpue1 ptcpue0 write: reset:00000000 = unimplemented figure 11-12. port c input pullup enable register (ptcpue) table 11-3. port c pin functions ptcpue bit ddrc bit ptc bit i/o pin mode accesses to ddrc accesses to ptc read/write read write 10 x (1) 1. x = don? care input, v dd (2) 2. i/o pin pulled to v dd by internal pullup. ddrc2?drc0 pin ptc3?tc0 (3) 3. writing affects data register, but does not affect input. 00x input, hi-z (4) 4. hi-z = high impedance ddrc2?drc0 pin ptc3?tc0 (3) x 1 x output ddrc2?drc0 ptc3?tc0 ptc3?tc0 bit 7654321bit 0 read: ptd7 ptd6 ptd5 ptd4 ptd3 ptd2 ptd1 ptd0 write: reset: unaffected by reset figure 11-13. port d data register (ptd)
port d mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 115 ptd[7:0] ?port d data bits these read/write bits are software programmable. data direction of each port d pin is under the control of the corresponding bit in data direction register d. reset has no effect on port d data. 11.6.2 data direction register d data direction register d (ddrd) determines whether each port d pin is an input or an output. writing a 1 to a ddrd bit enables the output buffer for the corresponding port d pin; a 0 disables the output buffer. ddrd[7:0] ?data direction register d bits these read/write bits control port d data direction. reset clears ddrd[7:0], configuring all port d pins as inputs. 1 = corresponding port d pin configured as output 0 = corresponding port d pin configured as input note avoid glitches on port d pins by writing to the port d data register before changing data direction register d bits from 0 to 1. figure 11-15 shows the port d i/o logic. figure 11-15. port d i/o circuit when ddrdx is a 1, reading address $0003 reads the ptdx data latch. when ddrdx is a 0, reading address $0003 reads the voltage level on the pin. the data latch can always be written, regardless of the state of its data direction bit. bit 7 6 5 4 3 2 1 bit 0 read: ddrd7 ddrd6 ddrd5 ddrd4 ddrd3 ddrd2 ddrd1 ddrd0 write: reset:00000000 figure 11-14. data direction register d (ddrd) read ddrd ($0007) write ddrd ($0007) reset write ptd ($0003) read ptd ($0003) ptdx ddrdx ptdx internal data bus pullup ptdpuex
input/output ports (ports) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 116 freescale semiconductor 11.6.3 port d input pullup enable register the port d input pullup enable register (ptdpue) contains a software configurable pullup device for each of the eight port d pins. each bit is individually configurable and requires the corresponding data direction register, ddrdx, be configured as input. each pullup device is automatically and dynamically disabled when its corresponding ddrdx bit is configured as output. ptdpue[7:0] ?port d input pullup enable bits these read/write bits are software programmable to enable pullup devices on port d pins 1 = corresponding port d pin configured to have internal pull if its ddrd bit is set to 0 0 = pullup device is disconnected on the corresponding port d pin regardless of the state of its ddrd bit. table 11-4 summarizes the operation of the port d pins. bit 7 6 5 4 3 2 1 bit 0 read: ptdpue7 ptdpue6 ptdpue5 ptdpue4 ptdpue3 ptdpue2 ptdpue1 ptdpue0 write: reset: 00000000 figure 11-16. port d input pullup enable register (ptdpue) table 11-4. port d pin functions ptdpue bit ddrd bit ptd bit i/o pin mode accesses to ddrd accesses to ptd read/write read write 10 x (1) 1. x = don? care input, v dd (2) 2. i/o pin pulled to v dd by internal pullup. ddrd7?drd0 pin ptd7?td0 (3) 3. writing affects data register, but does not affect input. 00x input, hi-z (4) 4. hi-z = high impedance ddrd7?drd0 pin ptd7?td0 (3) x 1 x output ddrd7?drd0 ptd7?td0 ptd7?td0
mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 117 chapter 12 periodic wakeup module (pwu) 12.1 introduction this section describes the periodic wakeup (pwu) module.the pwu is available in all modes of operation (run, wait, and stop) and performs two main functions: generate periodic wakeup requests to bring the microcontroller unit (mcu) out of stop mode. generate periodic interrupt requests during run and wait modes. 12.2 features features of the periodic wakeup module include: interrupt with separate interrupt enable bit, interrupt vector and interrupt mask bit exit from low-power stop mode without external signals programmable clock input selectable timeout periods (40 s to 3 minutes with an adjustment resolution of better than 1% for periods over 4 ms) dedicated low-power 32 khz internal oscillator separate from the main system clock sources option to allow bus clock source to run the pwu accessible in all modes of operation (run, wait, and stop) 12.3 functional description figure 12-1 is a block diagram of the pwu. the pwu module consists of a pwu counter whose count is reset once it equals the value stored in the pwu modulo register (pwumod). the pwu counter clock, pwuclock, frequency is selectable using the pwu prescaler register (pwup). the prescaler clock source can be selected using the pwuclksel bit in the pwu status and control register (pwusc) and can either be the internal rc oscillator or the busclkx4 clock.the pwuclksel bit, pwumod and pwup registers can only be written to when the pwuon bit is clear. the pwuon bit in pwusc is used to enable the pwu module. the smode bit in pwusc is used to allow an enabled pwu module to continue running in stop mode. busclkx4 must be enabled to run in stop mode if used as the clock source for the pwu when smode is set. see chapter 4 configuration registers (config1 and config2) on enabling busclkx4 to run in stop mode. the pwu counter when enabled will count until it reaches the value stored in the pwu modulo register (pwumod), when they are equal the read-only pwu flag (pwuf) in pwusc is latched. the pwu interrupt enable bit, pwuie, in pwusc enables a pwu interrupt request. the pwuf can be cleared by writing to the pwu acknowledge bit, pwuack in pwusc or by a pwu interrupt vector fetch.
periodic wakeup module (pwu) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 118 freescale semiconductor figure 12-1. periodic wakeup interrupt request generation logic once the modulo value has been reached, the counter will be reset to $00. the pwu counter is also reset when the module is disabled, or when the mcu enters stop mode with smode clear. the periodic wakeup rc oscillator is highly dependent on operating voltage and temperature and consequently would provide limited accuracy if used as a time-keeping function. 12.4 interrupts the following pwu source can generate interrupt requests: pwu flag (pwuf) ?the pwuf bit is set when the counter reaches the modulo value programmed in the pwumod register. the pwu interrupt enable bit, pwuie, enables pwu interrupt requests. pwuf and pwuie are in the pwusc register. 12.5 low-power modes the wait and stop instructions put the mcu in low power-consumption standby modes. 12.5.1 wait mode the pwu module remains active in wait mode while the pwuon bit in pwusc is set. setting pwuie in pwusc enables pwu interrupts to bring the mcu out of wait mode. if the pwu is not required during wait mode, power consumption can be reduced by disabling the pwu module (pwuon = 0) before entering wait mode. d r v dd internal rc en 32 khz clk rst counter = pwumod e reset pwuack st op pwuireq reset pwuf q pwuie busclkx4 pwuclksel m u x pwu clock prescaler pwup smode pwuon oscillator note: pwuclksel bit, pwumod and pwup registers can only be written to with pwuon=0 stop is an internal mcu signal and when stop = 0, indicates the mcu is in stop mode. reset is an internal mcu signal, indicates the mcu has taken a reset. busclkx4 is an internal mcu clock source, used to create the bus frequency for the mcu. pwuireq is an internal mcu signal, used to request an interrupt to the mcu. 1 0 en pwuclksel pwumod =? pwu counter pwu clock source vector fetch decoder
pwu during break interrupts mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 119 12.5.2 stop mode the pwu module remains active in stop mode while the pwuon and smode bits in pwusc is set. setting pwuie in pwusc enables pwu interrupts to bring the mcu out of stop mode. 12.6 pwu during break interrupts the system integration module (sim) controls whether status bits in other modules can be cleared during the break state. the bcfe bit in the break flag control register (bfcr) enables software to clear status bits during the break state. see bfcr in the sim section of this data sheet. to allow software to clear status bits during a break interrupt, write a 1 to bcfe. if a status bit is cleared during the break state, it remains cleared when the mcu exits the break state. to protect status bits during the break state, write a 0 to bcfe. with bcfe cleared (its default state), software can read and write registers during the break state without affecting status bits. some status bits have a two-step read/write clearing procedure. if software does the first step on such a bit before the break, the bit cannot change during the break state as long as bcfe is cleared. after the break, doing the second step clears the status bit. 12.7 i/o signals the pwu module is not associated with any external i/o pins. 12.8 registers the pwu registers control and monitor operation of the pwu. the registers that are relevant to the use of the pwu are as follows. periodic wakeup status and control register (pwusc) periodic wakeup prescaler register (pwup) periodic wakeup modulo register (pwumod) 12.8.1 periodic wakeup status and control register the pwusc register contains bits that: enables or disables the periodic wakeup module selects the clock source to the periodic wakeup prescaler register flags periodic wakeup interrupt requests acknowledges periodic wakeup interrupts enables or disables periodic wakeup interrupts enables or disables the module during stop mode bit 7 6 5 4 3 2 1 bit 0 read: 0 0 pwuon pwuclksel pwuf 0 pwuie smode write: pwuack reset:000 0 0000 = unimplemented figure 12-2. periodic wakeup status and control register (pwusc)
periodic wakeup module (pwu) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 120 freescale semiconductor pwuon ?periodic wakeup enabled bit this read/write bit enables or disables the periodic wakeup module. 1 = periodic wakeup module is enabled. 0 = periodic wakeup module is disabled. pwuclksel ?periodic wakeup clock select bit this read/write bit selects the clock source for the prescaler. 1 = busclkx4 is selected as the clock source for the prescaler. 0 = the internal 32 khz rc oscillator is selected as the clock source for the prescaler. note the pwuclksel bit can only be written to when pwuon is clear. pwuf ?periodic wakeup flag bit this read-only bit is set when the counter reaches the modulo value programmed in the pwumod register. this bit is cleared by writing a 1 to the pwuack bit or by a pwu interrupt vector fetch. 1 = periodic wakeup interrupt pending 0 = no periodic wakeup interrupt pending. pwuack ?periodic wakeup acknowledge bit writing a 1 to this write-only bit clears the pwuf. pwuack always reads as 0. pwuie ?periodic wakeup interrupt enable bit this read/write bit enables periodic wakeup interrupt requests. 1 = periodic wakeup interrupt requests enabled. 0 = periodic wakeup interrupt requests disabled. smode ?periodic wakeup module enabled in stop mode bit this read/write bit is used to allow the pwu module to continue running in stop mode. 1 = periodic wakeup module continues to run in stop mode. 0 = periodic wakeup module disabled in stop mode. 12.8.2 periodic wakeup prescaler register the pwup register is used to select the clock rate that will be input to the pwu counter. the prescaler generates sixteen clock rates from either the dedicated low-power internal oscillator or from the bus clock source (busclkx4). ps3?s0 ?prescaler select bits these read/write bits select one of the sixteen prescaler outputs to be the input to the pwu counter. note the pwup register can only be written to when pwuon is clear. bit 7654321bit 0 read: 0000 ps3 ps2 ps1 ps0 write: reset:00000100 = unimplemented figure 12-3. periodic wakeup prescaler register (pwup)
registers mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 121 12.8.3 periodic wakeup modulo register the pwu modulo register contains the modulo value for the counter. when the counter reaches the modulo value, the pwu flag (pwuf) becomes set, and the counter resumes counting from $00 at the next pwu clock. if pwuie is set, a pwu interrupt is requested.the value in the pwumod register and the selected prescaler output determine the frequency of the periodic interrupt. the frequency of the periodic interrupt can be calculated by multiplying the prescaler period (see table 12-1 ) by the value in the modulo register. note the pwumod register can only be written to when pwuon is clear. table 12-1. prescaler selection ps3-ps0 pwu counter clock source (pwu clock divided by:) nominal period (@ 32khz) 0000 1 31.25 s 0001 2 62.5 s 0010 4 125 s 0011 8 250 s 0100 16 500 s 0101 32 1 ms 0110 64 2 ms 0111 128 4 ms 1000 256 8 ms 1001 512 16 ms 1010 1024 32 ms 1011 2048 64 ms 1100 4096 128 ms 1101 8192 256 ms 1110 16384 512 ms 1111 32768 1 s bit 7654321bit 0 read: bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 write: reset:00000000 figure 12-4. periodic wakeup modulo register (pwumod)
periodic wakeup module (pwu) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 122 freescale semiconductor
mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 123 chapter 13 enhanced serial communications interface (esci) module 13.1 introduction the enhanced serial communications interface (esci) module allows asynchronous communications with peripheral devices and other microcontroller units (mcu). the esci module shares its pins with general-purpose input/output (i/o) port pins. see figure 13-1 for port location of these shared pins. the esci baud rate clock source is controlled by a bit (escibdsrc) located in the configuration register. 13.2 features features include: full-duplex operation standard mark/space non-return-to-zero (nrz) format programmable baud rates programmable 8-bit or 9-bit character length separately enabled transmitter and receiver separate receiver and transmitter interrupt requests programmable transmitter output polarity receiver wakeup methods idle line address mark interrupt-driven operation with eight interrupt flags: transmitter empty transmission complete receiver full idle receiver input receiver overrun noise error framing error parity error receiver framing error detection hardware parity checking 1/16 bit-time noise detection
enhanced serial communications interface (esci) module mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 124 freescale semiconductor figure 13-1. block diagram highlighting esci block and pins all port pins can be configured with internal pullup ptc not available on 16-pin devices (see note in 11.1 introduction) ptd not available on 16-pin or 20-pin devices (see note in 11.1 introduction) pta0/t1ch0/ad0/kbi0 pta1/t1ch1/ad1/kbi1 pta2/ irq/kbi2/t1clk pta3/ rst/kbi3 pta4/osc2/ad2/kbi4 pta5/osc1/ad3/kbi5 4-channel 16-bit timer module keyboard interrupt module single interrupt module periodic wakeup low-voltage inhibit cop module 10-channel 10-bit adc enhanced serial ptb0/spsck/ad4 ptb ddrb m68hc08 cpu pta ddra ptb1/mosi/t2ch1/ad5 ptb2/miso/t2ch0/ad6 ptb3/ ss/t2clk/ad7 ptb4/rxd/t2ch0/ad8 ptb5/txd/t2ch1/ad9 ptb6/t1ch2 ptb7/t1ch3 power supply v dd v ss clock generator communications interface module module serial peripheral interface 16,384 bytes mc68hc908qc16 8192 bytes mc68hc908qc8 512 bytes mc68hc908qc16 384 bytes mc68hc908qc8 break module monitor rom 2-channel 16-bit timer module ptc0 ptc1 ptc2 ptc3 ptc ddrc ptd0 ptd ddrd ptd1 ptd2 ptd3 ptd4 ptd5 ptd6 ptd7 mc68hc908qc4 user ram user flash 4096 bytes 384 bytes mc68hc908qc4
functional description mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 125 13.3 functional description shows the structure of the esci module. the esci allows full-duplex, asynchronous, nrz serial communication between the mcu and remote devices, including other mcus. the transmitter and receiver of the esci operate independently, although they use the same baud rate generator. figure 13-2. esci module block diagram scte tc scrf idle or nf fe pe sctie tcie scrie ilie te re rwu sbk r8 t8 orie feie peie bkf rpf esci data receive shift register esci data register transmit shift register neie m wake ilty flag control transmit control receive control data selection control wakeup pty pen register transmitter interrupt control receiver interrupt control error interrupt control control ensci loops ensci internal bus txinv loops 4 16 pre- scaler baud rate generator escibdsrc rxd txd arbiter sci_txd rxd linr lint bus clock aclk bit in sciactl sl sci_clk enhanced prescaler sl from config bus busclkx4 clock sl = 1 -> sci_clk = busclk sl = 0 -> sci_clk = busclkx4 fegister
enhanced serial communications interface (esci) module mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 126 freescale semiconductor 13.3.1 data format the sci uses the standard mark/space non-return-to-zero (nrz) format illustrated in figure 13-3 . figure 13-3. sci data formats 13.3.2 transmitter figure 13-4 shows the structure of the sci transmitter. 13.3.2.1 character length the transmitter can accommodate either 8-bit or 9-bit data. the state of the m bit in esci control register 1 (scc1) determines character length. when transmitting 9-bit data, bit t8 in esci control register 3 (scc3) is the ninth bit (bit 8). 13.3.2.2 character transmission during an esci transmission, the transmit shift register shifts a character out to the txd pin. the esci data register (scdr) is the write-only buffer between the internal data bus and the transmit shift register. to initiate an esci transmission: 1. enable the esci by writing a 1 to the enable esci bit (ensci) in esci control register 1 (scc1). 2. enable the transmitter by writing a 1 to the transmitter enable bit (te) in esci control register 2 (scc2). 3. clear the esci transmitter empty bit (scte) by first reading esci status register 1 (scs1) and then writing to the scdr. for 9-bit data, also write the t8 bit in scc3. 4. repeat step 3 for each subsequent transmission. at the start of a transmission, transmitter control logic automatically loads the transmit shift register with a preamble of 1s. after the preamble shifts out, control logic transfers the scdr data into the transmit shift register. a 0 start bit automatically goes into the least significant bit (lsb) position of the transmit shift register. a 1 stop bit goes into the most significant bit (msb) position. the esci transmitter empty bit, scte, in scs1 becomes set when the scdr transfers a byte to the transmit shift register. the scte bit indicates that the scdr can accept new data from the internal data bus. if the esci transmit interrupt enable bit, sctie, in scc2 is also set, the scte bit generates a transmitter interrupt request. when the transmit shift register is not transmitting a character, the txd pin goes to the idle condition, high. if at any time software clears the ensci bit in esci control register 1 (scc1), the transmitter and receiver relinquish control of the port pins. bit 5 bit 0 bit 1 bit 0 bit 1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7 bit 8 bit 2 bit 3 bit 4 bit 6 bit 7 parity or data bit parity or data bit next start bit next start bit stop bit stop bit 8-bit data format (bit m in scc1 clear) 9-bit data format (bit m in scc1 set) start bit start bit
functional description mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 127 figure 13-4. esci transmitter 13.3.2.3 break characters writing a 1 to the send break bit, sbk, in scc2 loads the transmit shift register with a break character. for txinv = 0 (output not inverted), a transmitted break character contains all 0s and has no start, stop, or parity bit. break character length depends on the m bit in scc1 and the linr bits in scbr. as long as sbk is set, transmitter logic continuously loads break characters into the transmit shift register. after software clears the sbk bit, the shift register finishes transmitting the last break character and then transmits at least one 1. the automatic 1 at the end of a break character guarantees the recognition of the start bit of the next character. when linr is cleared in scbr, the esci recognizes a break character when a start bit is followed by eight or nine 0 data bits and a 0 where the stop bit should be, resulting in a total of 10 or 11 consecutive 0 data bits. when linr is set in scbr, the esci recognizes a break character when a start bit is followed by 9 or 10 0 data bits and a 0 where the stop bit should be, resulting in a total of 11 or 12 consecutive 0 data bits. pen pty stop 876543210start 11-bit transmit t8 scte sctie tcie sbk tc parity generation msb esci data register load from scdr shift enable preamble (all ones) break (all zeros) transmitter control logic shift register tc sctie tcie scte m ensci loops te txinv internal bus 4 pre- scaler scp1 scp0 scr1 scr2 scr0 baud divider 16 sci_txd pre- scaler pds1 pds2 pds0 pssb3 pssb4 pssb2 pssb1 pssb0 lint transmitter interrupt request busclkx4 or bus clock
enhanced serial communications interface (esci) module mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 128 freescale semiconductor receiving a break character has these effects on esci registers: sets the framing error bit (fe) in scs1 sets the esci receiver full bit (scrf) in scs1 clears the esci data register (scdr) clears the r8 bit in scc3 sets the break flag bit (bkf) in scs2 may set the overrun (or), noise flag (nf), parity error (pe), or reception in progress flag (rpf) bits 13.3.2.4 idle characters for txinv = 0 (output not inverted), a transmitted idle character contains all 1s and has no start, stop, or parity bit. idle character length depends on the m bit in scc1. the preamble is a synchronizing idle character that begins every transmission. if the te bit is cleared during a transmission, the txd pin becomes idle after completion of the transmission in progress. clearing and then setting the te bit during a transmission queues an idle character to be sent after the character currently being transmitted. 13.3.2.5 inversion of transmitted output the transmit inversion bit (txinv) in esci control register 1 (scc1) reverses the polarity of transmitted data. all transmitted values including idle, break, start, and stop bits, are inverted when txinv is set. see 13.8.1 esci control register 1. 13.3.3 receiver figure 13-5 shows the structure of the esci receiver. 13.3.3.1 character length the receiver can accommodate either 8-bit or 9-bit data. the state of the m bit in esci control register 1 (scc1) determines character length. when receiving 9-bit data, bit r8 in esci control register 3 (scc3) is the ninth bit (bit 8). when receiving 8-bit data, bit r8 is a copy of the eighth bit (bit 7). 13.3.3.2 character reception during an esci reception, the receive shift register shifts characters in from the rxd pin. the esci data register (scdr) is the read-only buffer between the internal data bus and the receive shift register. after a complete character shifts into the receive shift register, the data portion of the character transfers to the scdr. the esci receiver full bit, scrf, in esci status register 1 (scs1) becomes set, indicating that the received byte can be read. if the esci receive interrupt enable bit, scrie, in scc2 is also set, the scrf bit generates a receiver interrupt request.
functional description mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 129 figure 13-5. esci receiver block diagram all ones all zeros m wake ilty pen pty bkf rpf h876543210l 11-bit receive shift register stop start data recovery or orie nf neie fe feie pe peie scrie scrf ilie idle wakeup logic parity checking msb esci data register r8 scrie ilie rwu scrf idle internal bus pre- scaler baud divider 4 16 scp1 scp0 scr1 scr2 scr0 rxd pre- scaler pds1 pds2 pds0 pssb3 pssb4 pssb2 pssb1 pssb0 linr orie neie feie peie or nf fe pe busclkx4 or bus clock interrupt request error interrupt receiver request
enhanced serial communications interface (esci) module mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 130 freescale semiconductor 13.3.3.3 data sampling the receiver samples the rxd pin at the rt clock rate. the rt clock is an internal signal with a frequency 16 times the baud rate. to adjust for baud rate mismatch, the rt clock is resynchronized at these times (see figure 13-6 ): after every start bit after the receiver detects a data bit change from 1 to 0 (after the majority of data bit samples at rt8, rt9, and rt10 returns a valid 1 and the majority of the next rt8, rt9, and rt10 samples returns a valid 0) to locate the start bit, data recovery logic does an asynchronous search for a 0 preceded by three 1s. when the falling edge of a possible start bit occurs, the rt clock begins to count to 16. figure 13-6. receiver data sampling to verify the start bit and to detect noise, data recovery logic takes samples at rt3, rt5, and rt7. table 13-1 summarizes the results of the start bit verification samples. if start bit verification is not successful, the rt clock is reset and a new search for a start bit begins. table 13-1. start bit veri?ation rt3, rt5, and rt7 samples start bit verification noise flag 000 yes 0 001 yes 1 010 yes 1 011 no 0 100 yes 1 101 no 0 110 no 0 111 no 0 rt clock reset rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt2 rt3 rt4 rt5 rt8 rt7 rt6 rt11 rt10 rt9 rt15 rt14 rt13 rt12 rt16 rt1 rt2 rt3 rt4 start bit qualification start bit verification data sampling samples rt clock rt clock state start bit lsb rxd
functional description mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 131 to determine the value of a data bit and to detect noise, recovery logic takes samples at rt8, rt9, and rt10. table 13-2 summarizes the results of the data bit samples. note the rt8, rt9, and rt10 samples do not affect start bit verification. if any or all of the rt8, rt9, and rt10 start bit samples are 1s following a successful start bit verification, the noise flag (nf) is set and the receiver assumes that the bit is a start bit. to verify a stop bit and to detect noise, recovery logic takes samples at rt8, rt9, and rt10. table 13-3 summarizes the results of the stop bit samples. 13.3.3.4 framing errors if the data recovery logic does not detect a 1 where the stop bit should be in an incoming character, it sets the framing error bit, fe, in scs1. a break character also sets the fe bit because a break character has no stop bit. the fe bit is set at the same time that the scrf bit is set. 13.3.3.5 baud rate tolerance a transmitting device may be operating at a baud rate below or above the receiver baud rate. accumulated bit time misalignment can cause one of the three stop bit data samples to fall outside the actual stop bit. then a noise error occurs. if more than one of the samples is outside the stop bit, a framing table 13-2. data bit recovery rt8, rt9, and rt10 samples data bit determination noise flag 000 0 0 001 0 1 010 0 1 011 1 1 100 0 1 101 1 1 110 1 1 111 1 0 table 13-3. stop bit recovery rt8, rt9, and rt10 samples framing error flag noise flag 000 1 0 001 1 1 010 1 1 011 0 1 100 1 1 101 0 1 110 0 1 111 0 0
enhanced serial communications interface (esci) module mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 132 freescale semiconductor error occurs. in most applications, the baud rate tolerance is much more than the degree of misalignment that is likely to occur. as the receiver samples an incoming character, it resynchronizes the rt clock on any valid falling edge within the character. resynchronization within characters corrects misalignments between transmitter bit times and receiver bit times. slow data tolerance figure 13-7 shows how much a slow received character can be misaligned without causing a noise error or a framing error. the slow stop bit begins at rt8 instead of rt1 but arrives in time for the stop bit data samples at rt8, rt9, and rt10. figure 13-7. slow data for an 8-bit character, data sampling of the stop bit takes the receiver 9 bit times 16 rt cycles + 10 rt cycles = 154 rt cycles. with the misaligned character shown in figure 13-7 , the receiver counts 154 rt cycles at the point when the count of the transmitting device is 9 bit times 16 rt cycles + 3 rt cycles = 147 rt cycles. the maximum percent difference between the receiver count and the transmitter count of a slow 8-bit character with no errors is: for a 9-bit character, data sampling of the stop bit takes the receiver 10 bit times 16 rt cycles + 10 rt cycles = 170 rt cycles. with the misaligned character shown in figure 13-7 , the receiver counts 170 rt cycles at the point when the count of the transmitting device is 10 bit times 16 rt cycles + 3 rt cycles = 163 rt cycles. the maximum percent difference between the receiver count and the transmitter count of a slow 9-bit character with no errors is: msb stop rt1 rt2 rt3 rt4 rt5 rt6 rt7 rt8 rt9 rt10 rt11 rt12 rt13 rt14 rt15 rt16 data samples receiver rt clock 154 147 154 ------------------------- - 100 4.54%= 170 163 170 ------------------------- - 100 4.12%=
functional description mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 133 fast data tolerance figure 13-8 shows how much a fast received character can be misaligned without causing a noise error or a framing error. the fast stop bit ends at rt10 instead of rt16 but is still there for the stop bit data samples at rt8, rt9, and rt10. figure 13-8. fast data for an 8-bit character, data sampling of the stop bit takes the receiver 9 bit times 16 rt cycles + 10 rt cycles = 154 rt cycles. with the misaligned character shown in figure 13-8 , the receiver counts 154 rt cycles at the point when the count of the transmitting device is 10 bit times 16 rt cycles = 160 rt cycles. the maximum percent difference between the receiver count and the transmitter count of a fast 8-bit character with no errors is for a 9-bit character, data sampling of the stop bit takes the receiver 10 bit times 16 rt cycles + 10 rt cycles = 170 rt cycles. with the misaligned character shown in figure 13-8 , the receiver counts 170 rt cycles at the point when the count of the transmitting device is 11 bit times 16 rt cycles = 176 rt cycles. the maximum percent difference between the receiver count and the transmitter count of a fast 9-bit character with no errors is: 13.3.3.6 receiver wakeup so that the mcu can ignore transmissions intended only for other receivers in multiple-receiver systems, the receiver can be put into a standby state. setting the receiver wakeup bit, rwu, in scc2 puts the receiver into a standby state during which receiver interrupts are disabled. depending on the state of the wake bit in scc1, either of two conditions on the rxd pin can bring the receiver out of the standby state: 1. address mark ?an address mark is a 1 in the msb position of a received character. when the wake bit is set, an address mark wakes the receiver from the standby state by clearing the rwu bit. the address mark also sets the esci receiver full bit, scrf. software can then compare the character containing the address mark to the user-defined address of the receiver. if they are the same, the receiver remains awake and processes the characters that follow. if they are not the same, software can set the rwu bit and put the receiver back into the standby state. idle or next character stop rt1 rt2 rt3 rt4 rt5 rt6 rt7 rt8 rt9 rt10 rt11 rt12 rt13 rt14 rt15 rt16 data samples receiver rt clock 154 160 e 154 ------------------------- - 100 3.90%.= 170 176 e 170 ------------------------- - 100 3.53%.=
enhanced serial communications interface (esci) module mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 134 freescale semiconductor 2. idle input line condition when the wake bit is clear, an idle character on the rxd pin wakes the receiver from the standby state by clearing the rwu bit. the idle character that wakes the receiver does not set the receiver idle bit, idle, or the esci receiver full bit, scrf. the idle line type bit, ilty, determines whether the receiver begins counting 1s as idle character bits after the start bit or after the stop bit. note with the wake bit clear, setting the rwu bit after the rxd pin has been idle will cause the receiver to wake up. 13.4 interrupts the following sources can generate esci interrupt requests: 13.4.1 transmitter interrupts these conditions can generate interrupt requests from the esci transmitter: esci transmitter empty (scte) the scte bit in scs1 indicates that the scdr has transferred a character to the transmit shift register. scte can generate a transmitter interrupt request. setting the esci transmit interrupt enable bit, sctie, in scc2 enables the scte bit to generate transmitter interrupt requests. transmission complete (tc) ?the tc bit in scs1 indicates that the transmit shift register and the scdr are empty and that no break or idle character has been generated. the transmission complete interrupt enable bit, tcie, in scc2 enables the tc bit to generate transmitter interrupt requests. 13.4.2 receiver interrupts these sources can generate interrupt requests from the esci receiver: esci receiver full (scrf) ?the scrf bit in scs1 indicates that the receive shift register has transferred a character to the scdr. scrf can generate a receiver interrupt request. setting the esci receive interrupt enable bit, scrie, in scc2 enables the scrf bit to generate receiver interrupts. idle input (idle) the idle bit in scs1 indicates that 10 or 11 consecutive 1s shifted in from the rxd pin. the idle line interrupt enable bit, ilie, in scc2 enables the idle bit to generate interrupt requests. 13.4.3 error interrupts these receiver error flags in scs1 can generate interrupt requests: receiver overrun (or) ?the or bit indicates that the receive shift register shifted in a new character before the previous character was read from the scdr. the previous character remains in the scdr, and the new character is lost. the overrun interrupt enable bit, orie, in scc3 enables or to generate esci error interrupt requests. noise flag (nf) ?the nf bit is set when the esci detects noise on incoming data or break characters, including start, data, and stop bits. the noise error interrupt enable bit, neie, in scc3 enables nf to generate esci error interrupt requests.
low-power modes mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 135 framing error (fe) the fe bit in scs1 is set when a 0 occurs where the receiver expects a stop bit. the framing error interrupt enable bit, feie, in scc3 enables fe to generate esci error interrupt requests. parity error (pe) ?the pe bit in scs1 is set when the esci detects a parity error in incoming data. the parity error interrupt enable bit, peie, in scc3 enables pe to generate esci error interrupt requests. 13.5 low-power modes the wait and stop instructions put the mcu in low power-consumption standby modes. 13.5.1 wait mode the esci module remains active in wait mode. any enabled interrupt request from the esci module can bring the mcu out of wait mode. if esci module functions are not required during wait mode, reduce power consumption by disabling the module before executing the wait instruction. 13.5.2 stop mode the esci module is inactive in stop mode. the stop instruction does not affect esci register states. esci module operation resumes after the mcu exits stop mode. because the internal clock is inactive during stop mode, entering stop mode during an esci transmission or reception results in invalid data. 13.6 esci during break interrupts the system integration module (sim) controls whether status bits in other modules can be cleared during the break state. the bcfe bit in the break flag control register (bfcr) enables software to clear status bits during the break state. see bfcr in the sim section of this data sheet. to allow software to clear status bits during a break interrupt, write a 1 to bcfe. if a status bit is cleared during the break state, it remains cleared when the mcu exits the break state. to protect status bits during the break state, write a 0 to bcfe. with bcfe cleared (its default state), software can read and write registers during the break state without affecting status bits. some status bits have a two-step read/write clearing procedure. if software does the first step on such a bit before the break, the bit cannot change during the break state as long as bcfe is cleared. after the break, doing the second step clears the status bit. 13.7 i/o signals the esci module can share its pins with the general-purpose i/o pins. see figure 13-1 for the port pins that are shared. 13.7.1 esci transmit data (txd) the txd pin is the serial data output from the esci transmitter. when the esci is enabled, the txd pin becomes an output.
enhanced serial communications interface (esci) module mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 136 freescale semiconductor 13.7.2 esci receive data (rxd) the rxd pin is the serial data input to the esci receiver. when the esci is enabled, the rxd pin becomes an input. 13.8 registers the following registers control and monitor operation of the esci: esci control register 1, scc1 esci control register 2, scc2 esci control register 3, scc3 esci status register 1, scs1 esci status register 2, scs2 esci data register, scdr esci baud rate register, scbr esci prescaler register, scpsc esci arbiter control register, sciactl esci arbiter data register, sciadat 13.8.1 esci control register 1 esci control register 1 (scc1): enables loop mode operation enables the esci controls output polarity controls character length controls esci wakeup method controls idle character detection enables parity function controls parity type loops ?loop mode select bit this read/write bit enables loop mode operation. in loop mode the rxd pin is disconnected from the esci, and the transmitter output goes into the receiver input. both the transmitter and the receiver must be enabled to use loop mode. 1 = loop mode enabled 0 = normal operation enabled bit 7654321bit 0 read: loops ensci txinv m wake ilty pen pty write: reset:00000000 figure 13-9. esci control register 1 (scc1)
registers mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 137 ensci ?enable esci bit this read/write bit enables the esci and the esci baud rate generator. clearing ensci sets the scte and tc bits in esci status register 1 and disables transmitter interrupts. 1 = esci enabled 0 = esci disabled txinv ?transmit inversion bit this read/write bit reverses the polarity of transmitted data. 1 = transmitter output inverted 0 = transmitter output not inverted note setting the txinv bit inverts all transmitted values including idle, break, start, and stop bits. m ?mode (character length) bit this read/write bit determines whether esci characters are eight or nine bits long (see table 13-4 ). the ninth bit can serve as a receiver wakeup signal or as a parity bit. 1 = 9-bit esci characters 0 = 8-bit esci characters wake ?wakeup condition bit this read/write bit determines which condition wakes up the esci: a 1 (address mark) in the msb position of a received character or an idle condition on the rxd pin. 1 = address mark wakeup 0 = idle line wakeup ilty ?idle line type bit this read/write bit determines when the esci starts counting 1s as idle character bits. the counting begins either after the start bit or after the stop bit. if the count begins after the start bit, then a string of 1s preceding the stop bit may cause false recognition of an idle character. beginning the count after the stop bit avoids false idle character recognition, but requires properly synchronized transmissions. 1 = idle character bit count begins after stop bit 0 = idle character bit count begins after start bit pen ?parity enable bit this read/write bit enables the esci parity function (see table 13-4 ). when enabled, the parity function inserts a parity bit in the msb position (see table 13-2 ). 1 = parity function enabled 0 = parity function disabled table 13-4. character format selection control bits character format m pen:pty start bits data bits parity stop bits character length 0 0 x 1 8 none 1 10 bits 1 0 x 1 9 none 1 11 bits 0 1 0 1 7 even 1 10 bits 0 1 1 1 7 odd 1 10 bits 1 1 0 1 8 even 1 11 bits 1 1 1 1 8 odd 1 11 bits
enhanced serial communications interface (esci) module mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 138 freescale semiconductor pty ?parity bit this read/write bit determines whether the esci generates and checks for odd parity or even parity (see table 13-4 ). 1 = odd parity 0 = even parity note changing the pty bit in the middle of a transmission or reception can generate a parity error. 13.8.2 esci control register 2 esci control register 2 (scc2): enables these interrupt requests: scte bit to generate transmitter interrupt requests tc bit to generate transmitter interrupt requests scrf bit to generate receiver interrupt requests idle bit to generate receiver interrupt requests enables the transmitter enables the receiver enables esci wakeup transmits esci break characters sctie ?esci transmit interrupt enable bit this read/write bit enables the scte bit to generate esci transmitter interrupt requests. setting the sctie bit in scc2 enables the scte bit to generate interrupt requests. 1 = scte enabled to generate interrupt 0 = scte not enabled to generate interrupt tcie ?transmission complete interrupt enable bit this read/write bit enables the tc bit to generate esci transmitter interrupt requests. 1 = tc enabled to generate interrupt requests 0 = tc not enabled to generate interrupt requests scrie ?esci receive interrupt enable bit this read/write bit enables the scrf bit to generate esci receiver interrupt requests. setting the scrie bit in scc2 enables the scrf bit to generate interrupt requests. 1 = scrf enabled to generate interrupt 0 = scrf not enabled to generate interrupt bit 7654321bit 0 read: sctie tcie scrie ilie te re rwu sbk write: reset:00000000 figure 13-10. esci control register 2 (scc2)
registers mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 139 ilie ?idle line interrupt enable bit this read/write bit enables the idle bit to generate esci receiver interrupt requests. 1 = idle enabled to generate interrupt requests 0 = idle not enabled to generate interrupt requests te ?transmitter enable bit setting this read/write bit begins the transmission by sending a preamble of 10 or 11 1s from the transmit shift register to the txd pin. if software clears the te bit, the transmitter completes any transmission in progress before the txd returns to the idle condition (high). clearing and then setting te during a transmission queues an idle character to be sent after the character currently being transmitted. 1 = transmitter enabled 0 = transmitter disabled note writing to the te bit is not allowed when the enable esci bit (ensci) is clear. ensci is in esci control register 1. re ?receiver enable bit setting this read/write bit enables the receiver. clearing the re bit disables the receiver but does not affect receiver interrupt flag bits. 1 = receiver enabled 0 = receiver disabled note writing to the re bit is not allowed when the enable esci bit (ensci) is clear. ensci is in esci control register 1. rwu ?receiver wakeup bit this read/write bit puts the receiver in a standby state during which receiver interrupts are disabled. the wake bit in scc1 determines whether an idle input or an address mark brings the receiver out of the standby state and clears the rwu bit. 1 = standby state 0 = normal operation sbk ?send break bit setting and then clearing this read/write bit transmits a break character followed by a 1. the 1 after the break character guarantees recognition of a valid start bit. if sbk remains set, the transmitter continuously transmits break characters with no 1s between them. 1 = transmit break characters 0 = no break characters being transmitted note do not toggle the sbk bit immediately after setting the scte bit. toggling sbk before the preamble begins causes the esci to send a break character instead of a preamble.
enhanced serial communications interface (esci) module mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 140 freescale semiconductor 13.8.3 esci control register 3 esci control register 3 (scc3): stores the ninth esci data bit received and the ninth esci data bit to be transmitted. enables these interrupts: receiver overrun noise error framing error parity error r8 ?received bit 8 when the esci is receiving 9-bit characters, r8 is the read-only ninth bit (bit 8) of the received character. r8 is received at the same time that the scdr receives the other 8 bits. when the esci is receiving 8-bit characters, r8 is a copy of the eighth bit (bit 7). t8 ?transmitted bit 8 when the esci is transmitting 9-bit characters, t8 is the read/write ninth bit (bit 8) of the transmitted character. t8 is loaded into the transmit shift register at the same time that the scdr is loaded into the transmit shift register. orie ?receiver overrun interrupt enable bit this read/write bit enables esci error interrupt requests generated by the receiver overrun bit, or. 1 = esci error interrupt requests from or bit enabled 0 = esci error interrupt requests from or bit disabled neie ?receiver noise error interrupt enable bit this read/write bit enables esci error interrupt requests generated by the noise error bit, ne. 1 = esci error interrupt requests from ne bit enabled 0 = esci error interrupt requests from ne bit disabled feie ?receiver framing error interrupt enable bit this read/write bit enables esci error interrupt requests generated by the framing error bit, fe. 1 = esci error interrupt requests from fe bit enabled 0 = esci error interrupt requests from fe bit disabled peie ?receiver parity error interrupt enable bit this read/write bit enables esci receiver interrupt requests generated by the parity error bit, pe. 1 = esci error interrupt requests from pe bit enabled 0 = esci error interrupt requests from pe bit disabled bit 7654321bit 0 read: r8 t8 r r orie neie feie peie write: reset:u0000000 = unimplemented r = reserved u = unaffected figure 13-11. esci control register 3 (scc3)
registers mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 141 13.8.4 esci status register 1 esci status register 1 (scs1) contains flags to signal these conditions: transfer of scdr data to transmit shift register complete transmission complete transfer of receive shift register data to scdr complete receiver input idle receiver overrun noisy data framing error parity error scte ?esci transmitter empty bit this clearable, read-only bit is set when the scdr transfers a character to the transmit shift register. scte can generate an esci transmitter interrupt request. when the sctie bit in scc2 is set, scte generates an esci transmitter interrupt request. in normal operation, clear the scte bit by reading scs1 with scte set and then writing to scdr 1 = scdr data transferred to transmit shift register 0 = scdr data not transferred to transmit shift register tc ?transmission complete bit this read-only bit is set when the scte bit is set, and no data, preamble, or break character is being transmitted. tc generates an esci transmitter interrupt request if the tcie bit in scc2 is also set. tc is cleared automatically when data, preamble, or break is queued and ready to be sent. there may be up to 1.5 transmitter clocks of latency between queueing data, preamble, and break and the transmission actually starting. 1 = no transmission in progress 0 = transmission in progress scrf ?esci receiver full bit this clearable, read-only bit is set when the data in the receive shift register transfers to the esci data register. scrf can generate an esci receiver interrupt request. when the scrie bit in scc2 is set the scrf generates a interrupt request. in normal operation, clear the scrf bit by reading scs1 with scrf set and then reading the scdr. 1 = received data available in scdr 0 = data not available in scdr idle ?receiver idle bit this clearable, read-only bit is set when 10 or 11 consecutive 1s appear on the receiver input. idle generates an esci receiver interrupt request if the ilie bit in scc2 is also set. clear the idle bit by reading scs1 with idle set and then reading the scdr. after the receiver is enabled, it must receive bit 7654321bit 0 read: scte tc scrf idle or nf fe pe write: reset:11000000 = unimplemented figure 13-12. esci status register 1 (scs1)
enhanced serial communications interface (esci) module mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 142 freescale semiconductor a valid character that sets the scrf bit before an idle condition can set the idle bit. also, after the idle bit has been cleared, a valid character must again set the scrf bit before an idle condition can set the idle bit. 1 = receiver input idle 0 = receiver input active (or idle since the idle bit was cleared) or ?receiver overrun bit this clearable, read-only bit is set when software fails to read the scdr before the receive shift register receives the next character. the or bit generates an esci error interrupt request if the orie bit in scc3 is also set. the data in the shift register is lost, but the data already in the scdr is not affected. clear the or bit by reading scs1 with or set and then reading the scdr. 1 = receive shift register full and scrf = 1 0 = no receiver overrun software latency may allow an overrun to occur between reads of scs1 and scdr in the flag-clearing sequence. figure 13-13 shows the normal flag-clearing sequence and an example of an overrun caused by a delayed flag-clearing sequence. the delayed read of scdr does not clear the or bit because or was not set when scs1 was read. byte 2 caused the overrun and is lost. the next flag-clearing sequence reads byte 3 in the scdr instead of byte 2. in applications that are subject to software latency or in which it is important to know which byte is lost due to an overrun, the flag-clearing routine can check the or bit in a second read of scs1 after reading the data register. figure 13-13. flag clearing sequence byte 1 normal flag clearing sequence scrf = 1 scrf = 1 byte 2 byte 3 byte 4 scrf = 0 scrf = 1 scrf = 0 scrf = 0 byte 1 scrf = 1 scrf = 1 byte 2 byte 3 byte 4 delayed flag clearing sequence or = 1 scrf = 1 or = 1 scrf = 0 or = 1 scrf = 0 or = 0 read scs1 scrf = 1 or = 0 read scs1 scrf = 1 or = 0 read scs1 scrf = 1 or = 0 read scdr byte 1 read scdr byte 2 read scdr byte 3 read scs1 scrf = 1 or = 0 read scs1 scrf = 1 or = 1 read scdr byte 1 read scdr byte 3
registers mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 143 nf ?receiver noise flag bit this clearable, read-only bit is set when the esci detects noise on the rxd pin. nf generates an nf interrupt request if the neie bit in scc3 is also set. clear the nf bit by reading scs1 and then reading the scdr. 1 = noise detected 0 = no noise detected fe ?receiver framing error bit this clearable, read-only bit is set when a 0 is accepted as the stop bit. fe generates an esci error interrupt request if the feie bit in scc3 also is set. clear the fe bit by reading scs1 with fe set and then reading the scdr. 1 = framing error detected 0 = no framing error detected pe ?receiver parity error bit this clearable, read-only bit is set when the esci detects a parity error in incoming data. pe generates a pe interrupt request if the peie bit in scc3 is also set. clear the pe bit by reading scs1 with pe set and then reading the scdr. 1 = parity error detected 0 = no parity error detected 13.8.5 esci status register 2 esci status register 2 (scs2) contains flags to signal these conditions: break character detected reception in progress bkf ?break flag bit this clearable, read-only bit is set when the esci detects a break character on the rxd pin. in scs1, the fe and scrf bits are also set. in 9-bit character transmissions, the r8 bit in scc3 is cleared. bkf does not generate a interrupt request. clear bkf by reading scs2 with bkf set and then reading the scdr. once cleared, bkf can become set again only after 1s again appear on the rxd pin followed by another break character. 1 = break character detected 0 = no break character detected rpf ?reception in progress flag bit this read-only bit is set when the receiver detects a 0 during the rt1 time period of the start bit search. rpf does not generate an interrupt request. rpf is reset after the receiver detects false start bits (usually from noise or a baud rate mismatch), or when the receiver detects an idle character. polling rpf before disabling the esci module or entering stop mode can show whether a reception is in progress. 1 = reception in progress 0 = no reception in progress bit 7654321bit 0 read: 000000bkfrpf write: reset:00000000 = unimplemented figure 13-14. esci status register 2 (scs2)
enhanced serial communications interface (esci) module mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 144 freescale semiconductor 13.8.6 esci data register the esci data register (scdr) is the buffer between the internal data bus and the receive and transmit shift registers. reset has no effect on data in the esci data register. r7/t7:r0/t0 ?receive/transmit data bits reading scdr accesses the read-only received data bits, r7:r0. writing to scdr writes the data to be transmitted, t7:t0. note do not use read-modify-write instructions on the esci data register. 13.8.7 esci baud rate register the esci baud rate register (scbr) together with the esci prescaler register selects the baud rate for both the receiver and the transmitter. note there are two prescalers available to adjust the baud rate ?one in the esci baud rate register and one in the esci prescaler register. lint ?lin transmit enable this read/write bit selects the enhanced esci features for the local interconnect network (lin) protocol as shown in table 13-5 . linr ?lin receiver bits this read/write bit selects the enhanced esci features for the local interconnect network (lin) protocol as shown in table 13-5 . in lin (version 1.2 and later) systems, the master node transmits a break character which will appear as 11.05?4.95 dominant bits to the slave node. a data character of 0x00 sent from the master might appear as 7.65?0.35 dominant bit times. this is due to the oscillator tolerance requirement that the slave node must be within 15%of the master node's oscillator. because a slave node cannot know if it is running faster or slower than the master node (prior to synchronization), the linr bit allows the slave node to differentiate between a 0x00 character of 10.35 bits and a break character of 11.05 bits. the break symbol length must be verified in software in any case, but the linr bit serves as a filter, preventing false detections of break characters that are really 0x00 data characters. bit 7654321bit 0 read: r7 r6 r5 r4 r3 r2 r1 r0 write: t7 t6 t5 t4 t3 t2 t1 t0 reset: unaffected by reset figure 13-15. esci data register (scdr) bit 7654321bit 0 read: lint linr scp1 scp0 r scr2 scr1 scr0 write: reset:00000000 r = reserved figure 13-16. esci baud rate register (scbr)
registers mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 145 scp1 and scp0 ?esci baud rate register prescaler bits these read/write bits select the baud rate register prescaler divisor as shown in table 13-6 . scr2?cr0 ?esci baud rate select bits these read/write bits select the esci baud rate divisor as shown in table 13-7 . reset clears scr2?cr0. 13.8.8 esci prescaler register the esci prescaler register (scpsc) together with the esci baud rate register selects the baud rate for both the receiver and the transmitter. note there are two prescalers available to adjust the baud rate ?one in the esci baud rate register and one in the esci prescaler register. table 13-5. esci lin control bits lint linr m functionality 0 0 x normal esci functionality 0 1 0 11-bit break detect enabled for lin receiver 0 1 1 12-bit break detect enabled for lin receiver 1 0 0 13-bit generation enabled for lin transmitter 1 0 1 14-bit generation enabled for lin transmitter 1 1 0 11-bit break detect/13-bit generation enabled for lin 1 1 1 12-bit break detect/14-bit generation enabled for lin table 13-6. esci baud rate prescaling scp[1:0] baud rate register prescaler divisor (bpd) 00 1 01 3 10 4 11 13 table 13-7. esci baud rate selection scr[2:1:0] baud rate divisor (bd) 000 1 001 2 010 4 011 8 100 16 101 32 110 64 1 1 1 128
enhanced serial communications interface (esci) module mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 146 freescale semiconductor pds2?ds0 ?prescaler divisor select bits these read/write bits select the prescaler divisor as shown in table 13-8 . note the setting of ?00 will bypass this prescaler. do not bypass the prescaler while ensci is set, because unexpected results may occur. pssb4?ssb0 ?clock insertion select bits these read/write bits select the number of clocks inserted in each 32 output cycle frame to achieve more timing resolution on the average prescaler frequency as shown in table 13-9 . use the following formula to calculate the esci baud rate: where: sci clock source = bus clock or busclkx4 (selected by escibdsrc in the configuration register) bpd = baud rate register prescaler divisor bd = baud rate divisor pd = prescaler divisor pdfa = prescaler divisor fine adjust table 13-10 shows the esci baud rates that can be generated with a 4.9152-mhz bus frequency. bit 7654321bit 0 read: pds2 pds1 pds0 pssb4 pssb3 pssb2 pssb1 pssb0 write: reset:00000000 figure 13-17. esci prescaler register (scpsc) table 13-8. esci prescaler division ratio pds[2:1:0] prescaler divisor (pd) 0 0 0 bypass this prescaler 001 2 010 3 011 4 100 5 101 6 110 7 111 8 frequency of the sci clock source 64 x bpd x bd x (pd + pdfa) baud rate =
registers mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 147 table 13-9. esci prescaler divisor fine adjust pssb[4:3:2:1:0] prescaler divisor fine adjust (pdfa) 00000 0/32 = 0 00001 1/32 = 0.03125 00010 2/32 = 0.0625 00011 3/32 = 0.09375 00100 4/32 = 0.125 00101 5/32 = 0.15625 00110 6/32 = 0.1875 00111 7/32 = 0.21875 01000 8/32 = 0.25 01001 9/32 = 0.28125 01010 10/32 = 0.3125 01011 11/32 = 0.34375 01100 12/32 = 0.375 01101 13/32 = 0.40625 01110 14/32 = 0.4375 01111 15/32 = 0.46875 10000 16/32 = 0.5 10001 17/32 = 0.53125 10010 18/32 = 0.5625 10011 19/32 = 0.59375 10100 20/32 = 0.625 10101 21/32 = 0.65625 10110 22/32 = 0.6875 10111 23/32 = 0.71875 11000 24/32 = 0.75 11001 25/32 = 0.78125 11010 26/32 = 0.8125 11011 27/32 = 0.84375 11100 28/32 = 0.875 11101 29/32 = 0.90625 11110 30/32 = 0.9375 11111 31/32 = 0.96875
enhanced serial communications interface (esci) module mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 148 freescale semiconductor table 13-10. esci baud rate selection examples pds[2:1:0] pssb[4:3:2:1:0] scp[1:0] prescaler divisor (bpd) scr[2:1:0] baud rate divisor (bd) baud rate (f bus = 4.9152 mhz) 0 0 0 x x x x x 0 0 1 0 0 0 1 76,800 111 00000 00 1 000 1 9600 111 00001 00 1 000 1 9562.65 111 00010 00 1 000 1 9525.58 111 11111 00 1 000 1 8563.07 0 0 0 x x x x x 0 0 1 0 0 1 2 38,400 0 0 0 x x x x x 0 0 1 0 1 0 4 19,200 0 0 0 x x x x x 0 0 1 0 1 1 8 9600 0 0 0 x x x x x 0 0 1 1 0 0 16 4800 0 0 0 x x x x x 0 0 1 1 0 1 32 2400 0 0 0 x x x x x 0 0 1 1 1 0 64 1200 0 0 0 x x x x x 0 0 1 1 1 1 128 600 0 0 0 x x x x x 0 1 3 0 0 0 1 25,600 0 0 0 x x x x x 0 1 3 0 0 1 2 12,800 0 0 0 x x x x x 0 1 3 0 1 0 4 6400 0 0 0 x x x x x 0 1 3 0 1 1 8 3200 0 0 0 x x x x x 0 1 3 1 0 0 16 1600 000 xxxxx 01 3 101 32 800 000 xxxxx 01 3 110 64 400 0 0 0 x x x x x 0 1 3 1 1 1 128 200 0 0 0 x x x x x 1 0 4 0 0 0 1 19,200 0 0 0 x x x x x 1 0 4 0 0 1 2 9600 0 0 0 x x x x x 1 0 4 0 1 0 4 4800 0 0 0 x x x x x 1 0 4 0 1 1 8 2400 0 0 0 x x x x x 1 0 4 1 0 0 16 1200 000 xxxxx 10 4 101 32 600 000 xxxxx 10 4 110 64 300 0 0 0 x x x x x 1 0 4 1 1 1 128 150 0 0 0 x x x x x 1 1 13 0 0 0 1 5908 0 0 0 x x x x x 1 1 13 0 0 1 2 2954 0 0 0 x x x x x 1 1 13 0 1 0 4 1477 000 xxxxx 11 13 011 8 739 000 xxxxx 11 13 100 16 369 000 xxxxx 11 13 101 32 185 000 xxxxx 11 13 110 64 92 000 xxxxx 11 13 111 128 46
esci arbiter mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 149 13.9 esci arbiter the esci module comprises an arbiter module designed to support software for communication tasks as bus arbitration, baud rate recovery and break time detection. the arbiter module consists of an 9-bit counter with 1-bit overflow and control logic. the can control operation mode via the esci arbiter control register (sciactl). 13.9.1 esci arbiter control register am1 and am0 ?arbiter mode select bits these read/write bits select the mode of the arbiter module as shown in table 13-11 . alost ?arbitration lost flag this read-only bit indicates loss of arbitration. clear alost by writing a 0 to am1. aclk ?arbiter counter clock select bit this read/write bit selects the arbiter counter clock source. 1 = arbiter counter is clocked with one half of the esci input clock generated by the esci prescaler 0 = arbiter counter is clocked with the bus clock divided by four note for aclk = 1, the arbiter input clock is driven from the esci prescaler. the prescaler can be clocked by either the bus clock or busclkx4 depending on the state of the escibdsrc bit in configuration register. afin?arbiter bit time measurement finish flag this read-only bit indicates bit time measurement has finished. clear afin by writing any value to sciactl. 1 = bit time measurement has finished 0 = bit time measurement not yet finished arun?arbiter counter running flag this read-only bit indicates the arbiter counter is running. 1 = arbiter counter running 0 = arbiter counter stopped bit 7654321bit 0 read: am1 alost am0 aclk afin arun arovfl ard8 write: reset:00000000 = unimplemented figure 13-18. esci arbiter control register (sciactl) table 13-11. esci arbiter selectable modes am[1:0] esci arbiter mode 0 0 idle / counter reset 0 1 bit time measurement 1 0 bus arbitration 1 1 reserved / do not use
enhanced serial communications interface (esci) module mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 150 freescale semiconductor arovfl?arbiter counter overflow bit this read-only bit indicates an arbiter counter overflow. clear arovfl by writing any value to sciactl. writing 0s to am1 and am0 resets the counter keeps it in this idle state. 1 = arbiter counter overflow has occurred 0 = no arbiter counter overflow has occurred ard8?arbiter counter msb this read-only bit is the msb of the 9-bit arbiter counter. clear ard8 by writing any value to sciactl. 13.9.2 esci arbiter data register ard7?rd0 ?arbiter least significant counter bits these read-only bits are the eight lsbs of the 9-bit arbiter counter. clear ard7?rd0 by writing any value to sciactl. writing 0s to am1 and am0 permanently resets the counter and keeps it in this idle state. 13.9.3 bit time measurement two bit time measurement modes, described here, are available according to the state of aclk. 1. aclk = 0 the counter is clocked with one quarter of the bus clock. the counter is started when a falling edge on the rxd pin is detected. the counter will be stopped on the next falling edge. arun is set while the counter is running, afin is set on the second falling edge on rxd (for instance, the counter is stopped). this mode is used to recover the received baud rate. see figure 13-20 . 2. aclk = 1 ?the counter is clocked with one half of the esci input clock generated by the esci prescaler. the counter is started when a 0 is detected on rxd (see figure 13-21 ). a 0 on rxd on enabling the bit time measurement with aclk = 1 leads to immediate start of the counter (see figure 13-22 ). the counter will be stopped on the next rising edge of rxd. this mode is used to measure the length of a received break. figure 13-20. bit time measurement with aclk = 0 bit 7654321bit 0 read: ard7 ard6 ard5 ard4 ard3 ard2 ard1 ard0 write: reset:00000000 = unimplemented figure 13-19. esci arbiter data register (sciadat) write sciact counter starts counter stops measured time read result rxd with $20 arun = 1 afin = 1 out of sciadat
esci arbiter mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 151 figure 13-21. bit time measurement with aclk = 1, scenario a figure 13-22. bit time measurement with aclk = 1, scenario b 13.9.4 arbitration mode if am[1:0] is set to 10, the arbiter module operates in arbitration mode. on every rising edge of sci_txd (output of the transmit shift register, see ), the counter is started. when the counter reaches $38 (aclk = 0) or $08 (aclk = 1), rxd is statically sensed. if in this case, rxd is sensed low (for example, another bus is driving the bus dominant) alost is set. as long as alost is set, the txd pin is forced to 1, resulting in a seized transmission. if sci_txd senses 0 without having sensed a 0 before on rxd, the counter will be reset, arbitration operation will be restarted after the next rising edge of sci_txd. write sciactl with $30 counter starts, arun = 1 counter stops, afin = 1 measured time read result rxd out of sciadat write sciactl counter starts counter stops measured time read result rxd out of sciadat afin = 1 arun = 1 with $30
enhanced serial communications interface (esci) module mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 152 freescale semiconductor
mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 153 chapter 14 system integration module (sim) 14.1 introduction this section describes the system integration module (sim), which supports up to 24 external and/or internal interrupts. together with the central processor unit (cpu), the sim controls all microcontroller unit (mcu) activities. a block diagram of the sim is shown in figure 14-1 . the sim is a system state controller that coordinates cpu and exception timing. the sim is responsible for: bus clock generation and control for cpu and peripherals stop/wait/reset/break entry and recovery internal clock control master reset control, including power-on reset (por) and computer operating properly (cop) timeout interrupt control: acknowledge timing arbitration control timing vector address generation cpu enable/disable timing 14.2 rst and irq pins initialization rst and irq pins come out of reset as pta3 and pta2 respectively. rst and irq functions can be activated by programing config2 accordingly. refer to chapter 4 configuration registers (config1 and config2). 14.3 sim bus clock control and generation the bus clock generator provides system clock signals for the cpu and peripherals on the mcu. the system clocks are generated from an incoming clock, busclkx2, as shown in figure 14-2 . table 14-1. signal name conventions signal name description busclkx4 buffered clock from the internal, rc or xtal oscillator circuit. busclkx2 the busclkx4 frequency divided by two. this signal is again divided by two in the sim to generate the internal bus clocks (bus clock = busclkx4 4). address bus internal address bus data bus internal data bus porrst signal from the power-on reset module to the sim irst internal reset signal r/ w read/write signal
system integration module (sim) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 154 freescale semiconductor figure 14-1. sim block diagram figure 14-2. sim clock signals stop/wait clock control clock generators por control reset pin control sim reset status register interrupt control and priority decode module stop module wait cpu stop (from cpu) cpu wait (from cpu) simoscen (to oscillator) busclkx2 (from oscillator) internal clocks master reset control reset pin logic illegal opcode (from cpu) illegal address (from address map decoders) cop timeout (from cop module) interrupt sources cpu interface reset control sim counter cop clock busclkx4 (from oscillator) 2 lvi reset (from lvi module) v dd internal pull-up forced mon mode entry (from menrst module) 2 bus clock generators sim sim counter from oscillator from oscillator busclkx2 busclkx4
reset and system initialization mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 155 14.3.1 bus timing in user mode, the internal bus frequency is the oscillator frequency (busclkx4) divided by four. 14.3.2 clock start-up from por when the power-on reset module generates a reset, the clocks to the cpu and peripherals are inactive and held in an inactive phase until after the 4096 busclkx4 cycle por time out has completed. the ibus clocks start upon completion of the time out. 14.3.3 clocks in stop mode and wait mode upon exit from stop mode by an interrupt or reset, the sim allows busclkx4 to clock the sim counter. the cpu and peripheral clocks do not become active until after the stop delay time out. this time out is selectable as 4096 or 32 busclkx4 cycles. see 14.7.2 stop mode. in wait mode, the cpu clocks are inactive. the sim also produces two sets of clocks for other modules. refer to the wait mode subsection of each module to see if the module is active or inactive in wait mode. some modules can be programmed to be active in wait mode. 14.4 reset and system initialization the mcu has these reset sources: power-on reset module (por) external reset pin ( rst) computer operating properly module (cop) low-voltage inhibit module (lvi) illegal opcode illegal address all of these resets produce the vector $fffe?fff ($fefe?eff in monitor mode) and assert the internal reset signal (irst). irst causes all registers to be returned to their default values and all modules to be returned to their reset states. an internal reset clears the sim counter (see 14.5 sim counter ), but an external reset does not. each of the resets sets a corresponding bit in the sim reset status register (srsr). see 14.8 sim registers. 14.4.1 external pin reset the rst pin circuits include an internal pullup device. pulling the asynchronous rst pin low halts all processing. the pin bit of the sim reset status register (srsr) is set as long as rst is held low for at least the minimum t rl time. figure 14-3 shows the relative timing. the rst pin function is only available if the rsten bit is set in the config2 register. figure 14-3. external reset timing rst address bus pc vect h vect l busclkx2
system integration module (sim) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 156 freescale semiconductor 14.4.2 active resets from internal sources the rst pin is initially setup as a general-purpose input after a por. setting the rsten bit in the config2 register enables the pin for the reset function. this section assumes the rsten bit is set when describing activity on the rst pin. note for por and lvi resets, the sim cycles through 4096 busclkx4 cycles. the internal reset signal then follows the sequence from the falling edge of rst shown in figure 14-4 . the cop reset is asynchronous to the bus clock. the active reset feature allows the part to issue a reset to peripherals and other chips within a system built around the mcu. all internal reset sources actively pull the rst pin low for 32 busclkx4 cycles to allow resetting of external peripherals. the internal reset signal irst continues to be asserted for an additional 32 cycles (see figure 14-4 ). an internal reset can be caused by an illegal address, illegal opcode, cop time out, lvi, or por (see figure 14-5 ). figure 14-4. internal reset timing figure 14-5. sources of internal reset table 14-2. reset recovery timing reset recovery type actual number of cycles por/lvi 4163 (4096 + 64 + 3) all others 67 (64 + 3) irst rst rst pulled low by mcu address 32 cycles 32 cycles vector high busclkx4 bus illegal address rst illegal opcode rst coprst por lvi internal reset
reset and system initialization mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 157 14.4.2.1 power-on reset when power is first applied to the mcu, the power-on reset module (por) generates a pulse to indicate that power on has occurred. the sim counter counts out 4096 busclkx4 cycles. sixty-four busclkx4 cycles later, the cpu and memories are released from reset to allow the reset vector sequence to occur. at power on, the following events occur: a por pulse is generated. the internal reset signal is asserted. the sim enables the oscillator to drive busclkx4. internal clocks to the cpu and modules are held inactive for 4096 busclkx4 cycles to allow stabilization of the oscillator. the por bit of the sim reset status register (srsr) is set. see figure 14-6 . figure 14-6. por recovery 14.4.2.2 computer operating properly (cop) reset an input to the sim is reserved for the cop reset signal. the overflow of the cop counter causes an internal reset and sets the cop bit in the sim reset status register (srsr). the sim actively pulls down the rst pin for all internal reset sources. to prevent a cop module time out, write any value to location $ffff. writing to location $ffff clears the cop counter and stages 12? of the sim counter. the sim counter output, which occurs at least every 4080 busclkx4 cycles, drives the cop counter. the cop should be serviced as soon as possible out of reset to guarantee the maximum amount of time before the first time out. the cop module is disabled during a break interrupt with monitor mode when bdcop bit is set in break auxiliary register (brkar). porrst osc1 busclkx4 busclkx2 rst address bus 4096 cycles 32 cycles 32 cycles $fffe $ffff ( rst pin is a general-purpose input after a por)
system integration module (sim) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 158 freescale semiconductor 14.4.2.3 illegal opcode reset the sim decodes signals from the cpu to detect illegal instructions. an illegal instruction sets the ilop bit in the sim reset status register (srsr) and causes a reset. if the stop enable bit, stop, in the mask option register is 0, the sim treats the stop instruction as an illegal opcode and causes an illegal opcode reset. the sim actively pulls down the rst pin for all internal reset sources. 14.4.2.4 illegal address reset an opcode fetch from an unmapped address generates an illegal address reset. the sim verifies that the cpu is fetching an opcode prior to asserting the ilad bit in the sim reset status register (srsr) and resetting the mcu. a data fetch from an unmapped address does not generate a reset. the sim actively pulls down the rst pin for all internal reset sources. see figure 2-1. memory map for memory ranges. 14.4.2.5 low-voltage inhibit (lvi) reset the lvi asserts its output to the sim when the v dd voltage falls to the lvi trip voltage v tripf . the lvi bit in the sim reset status register (srsr) is set, and the external reset pin ( rst) is held low while the sim counter counts out 4096 busclkx4 cycles after v dd rises above v tripr . sixty-four busclkx4 cycles later, the cpu and memories are released from reset to allow the reset vector sequence to occur. the sim actively pulls down the ( rst) pin for all internal reset sources. 14.5 sim counter the sim counter is used by the power-on reset module (por) and in stop mode recovery to allow the oscillator time to stabilize before enabling the internal bus (ibus) clocks. the sim counter also serves as a prescaler for the computer operating properly module (cop). the sim counter uses 12 stages for counting, followed by a 13th stage that triggers a reset of sim counters and supplies the clock for the cop module. the sim counter is clocked by the falling edge of busclkx4. 14.5.1 sim counter during power-on reset the power-on reset module (por) detects power applied to the mcu. at power-on, the por circuit asserts the signal porrst. once the sim is initialized, it enables the oscillator to drive the bus clock state machine. 14.5.2 sim counter during stop mode recovery the sim counter also is used for stop mode recovery. the stop instruction clears the sim counter. after an interrupt, break, or reset, the sim senses the state of the short stop recovery bit, ssrec, in the configuration register 1 (config1). if the ssrec bit is a 1, then the stop recovery is reduced from the normal delay of 4096 busclkx4 cycles down to 32 busclkx4 cycles. this is ideal for applications using canned oscillators that do not require long start-up times from stop mode. external crystal applications should use the full stop recovery time, that is, with ssrec cleared in the configuration register 1 (config1).
exception control mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 159 14.5.3 sim counter and reset states external reset has no effect on the sim counter (see 14.7.2 stop mode for details.) the sim counter is free-running after all reset states. see 14.4.2 active resets from internal sources for counter control and internal reset recovery sequences. 14.6 exception control normal sequential program execution can be changed in three different ways: 1. interrupts a. maskable hardware cpu interrupts b. non-maskable software interrupt instruction (swi) 2. reset 3. break interrupts 14.6.1 interrupts an interrupt temporarily changes the sequence of program execution to respond to a particular event. figure 14-7 flow charts the handling of system interrupts. interrupts are latched, and arbitration is performed in the sim at the start of interrupt processing. the arbitration result is a constant that the cpu uses to determine which vector to fetch. once an interrupt is latched by the sim, no other interrupt can take precedence, regardless of priority, until the latched interrupt is serviced (or the i bit is cleared). at the beginning of an interrupt, the cpu saves the cpu register contents on the stack and sets the interrupt mask (i bit) to prevent additional interrupts. at the end of an interrupt, the rti instruction recovers the cpu register contents from the stack so that normal processing can resume. figure 14-8 shows interrupt entry timing. figure 14-9 shows interrupt recovery timing. 14.6.1.1 hardware interrupts a hardware interrupt does not stop the current instruction. processing of a hardware interrupt begins after completion of the current instruction. when the current instruction is complete, the sim checks all pending hardware interrupts. if interrupts are not masked (i bit clear in the condition code register), and if the corresponding interrupt enable bit is set, the sim proceeds with interrupt processing; otherwise, the next instruction is fetched and executed. if more than one interrupt is pending at the end of an instruction execution, the highest priority interrupt is serviced first. figure 14-10 demonstrates what happens when two interrupts are pending. if an interrupt is pending upon exit from the original interrupt service routine, the pending interrupt is serviced before the lda instruction is executed. the lda opcode is prefetched by both the int1 and int2 return-from-interrupt (rti) instructions. however, in the case of the int1 rti prefetch, this is a redundant operation. note to maintain compatibility with the m6805 family , the h register is not pushed on the stack during interrupt entry. if the interrupt service routine modifies the h register or uses the indexed addressing mode, software should save the h register and then restore it prior to exiting the routine.
system integration module (sim) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 160 freescale semiconductor figure 14-7. interrupt processing no no no yes no no yes no yes yes (as many interrupts as exist on chip) i bit set? from reset break interrupt? i bit set? irq interrupt? timer interrupt? swi instruction? rti instruction? fetch next instruction unstack cpu registers execute instruction yes yes stack cpu registers set i bit load pc with interrupt vector
exception control mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 161 figure 14-8 . interrupt entry figure 14-9. interrupt recovery figure 14-10 . interrupt recognition example module data bus r/ w interrupt dummy sp sp ?1 sp ?2 sp ?3 sp ?4 vect h vect l start addr address bus dummy pc ?1[7:0] pc ?1[15:8] x a ccr v data h v data l opcode i bit module data bus r/ w interrupt sp ?4 sp ?3 sp ?2 sp ?1 sp pc pc + 1 address bus ccr a x pc ?1[7:0] pc ?1[15:8] opcode operand i bit cli lda int1 pulh rti int2 background routine #$ff pshh int1 interrupt service routine pulh rti pshh int2 interrupt service routine
system integration module (sim) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 162 freescale semiconductor 14.6.1.2 swi instruction the swi instruction is a non-maskable instruction that causes an interrupt regardless of the state of the interrupt mask (i bit) in the condition code register. note a software interrupt pushes pc onto the stack. a software interrupt does not push pc ?1, as a hardware interrupt does. 14.6.2 interrupt status registers the flags in the interrupt status registers identify maskable interrupt sources. table 14-3 summarizes the interrupt sources and the interrupt status register flags that they set. the interrupt status registers can be useful for debugging. table 14-3. interrupt sources priority source flag mask (1) 1. the i bit in the condition code register is a global mask for all interrupt sources except the swi instruction. int register flag vector address highest lowest reset $fffe?ffff swi instruction $fffc?fffd irq pin irqf imask if1 $fffa?fffb tim1 channel 0 interrupt ch0f ch0ie if3 $fff6?fff7 tim1 channel 1 interrupt ch1f ch1ie if4 $fff4?fff5 tim1 over?w interrupt tof toie if5 $fff2?fff3 tim1 channel 2 vector ch2f ch2ie if6 $fff0?fff1 tim1 channel 3 vector ch3f ch3ie if7 $ffee?ffef esci error vector or, hf, fe, pe orie, neie, feie, peie if9 $ffea?ffeb esci receive vector scrf scrie if10 $ffe8?ffe9 esci transmit vector scte, tc sctie, tcie if11 $ffe6?ffe7 spi receive sprf, ovrf, modf sprie, errie if12 $ffe4?ffe5 spi transmit spte sptie if13 $ffe2?ffe3 keyboard interrupt keyf imaskk if14 $ffe0?ffe1 adc conversion complete interrupt coco aien if15 $ffde?ffdf tim2 channel 0 interrupt ?g ch0f ch0ie if16 $ffdc?ffdd tim2 channel 1 interrupt ?g ch1f ch1ie if17 $ffda?ffdb tim2 over?w interrupt ?g tof toieint if18 $ffd8?ffd9 periodic wakeup interrupt ?g pwuf pwuie if19 $ffd6?ffd7
exception control mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 163 14.6.2.1 interrupt status register 1 if1?f6 ?interrupt flags these flags indicate the presence of interrupt requests from the sources shown in table 14-3 . 1 = interrupt request present 0 = no interrupt request present bit 0 and 1?always read 0 14.6.2.2 interrupt status register 2 if7? f 14 ?interrupt flags this flag indicates the presence of interrupt requests from the sources shown in table 14-3 . 1 = interrupt request present 0 = no interrupt request present 14.6.2.3 interrupt status register 3 if22?f15 ?interrupt flags these flags indicate the presence of interrupt requests from the sources shown in table 14-3 . 1 = interrupt request present 0 = no interrupt request present 14.6.3 reset all reset sources always have equal and highest priority and cannot be arbitrated. bit 7654321bit 0 read: if6 if5 if4 if3 if2 if1 0 0 write: rrrrrrrr reset:00000000 r = reserved figure 14-11. interrupt status register 1 (int1) bit 7654321bit 0 read: if14 if13 if12 if11 if10 if9 if8 if7 write: rrrrrrrr reset:00000000 r = reserved figure 14-12. interrupt status register 2 (int2) bit 7654321bit 0 read: if22 if21 if20 if19 if18 if17 if16 if15 write: rrrrrrrr reset:00000000 r = reserved figure 14-13. interrupt status register 3 (int3)
system integration module (sim) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 164 freescale semiconductor 14.6.4 break interrupts the break module can stop normal program flow at a software programmable break point by asserting its break interrupt output. (see chapter 18 development support.) the sim puts the cpu into the break state by forcing it to the swi vector location. refer to the break interrupt subsection of each module to see how each module is affected by the break state. 14.6.5 status flag protection in break mode the sim controls whether status flags contained in other modules can be cleared during break mode. the user can select whether flags are protected from being cleared by properly initializing the break clear flag enable bit (bcfe) in the break flag control register (bfcr). protecting flags in break mode ensures that set flags will not be cleared while in break mode. this protection allows registers to be freely read and written during break mode without losing status flag information. setting the bcfe bit enables the clearing mechanisms. once cleared in break mode, a flag remains cleared even when break mode is exited. status flags with a two-step clearing mechanism for example, a read of one register followed by the read or write of another are protected, even when the first step is accomplished prior to entering break mode. upon leaving break mode, execution of the second step will clear the flag as normal. 14.7 low-power modes executing the wait or stop instruction puts the mcu in a low power- consumption mode for standby situations. the sim holds the cpu in a non-clocked state. the operation of each of these modes is described below. both stop and wait clear the interrupt mask (i) in the condition code register, allowing interrupts to occur. 14.7.1 wait mode in wait mode, the cpu clocks are inactive while the peripheral clocks continue to run. figure 14-14 shows the timing for wait mode entry. figure 14-14. wait mode entry timing a module that is active during wait mode can wake up the cpu with an interrupt if the interrupt is enabled. stacking for the interrupt begins one cycle after the wait instruction during which the interrupt occurred. in wait mode, the cpu clocks are inactive. refer to the wait mode subsection of each module to see if the module is active or inactive in wait mode. some modules can be programmed to be active in wait mode. wait addr + 1 same same address bus data bus previous data next opcode same wait addr same r/ w note: previous data can be operand data or the wait opcode, depending on the last instruction.
low-power modes mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 165 wait mode can also be exited by a reset (or break in emulation mode). a break interrupt during wait mode sets the sim break stop/wait bit, sbsw, in the break status register (bsr). if the cop disable bit, copd, in the configuration register is 0, then the computer operating properly module (cop) is enabled and remains active in wait mode. figure 14-15 and figure 14-16 show the timing for wait recovery. figure 14-15. wait recovery from interrupt figure 14-16. wait recovery from internal reset 14.7.2 stop mode in stop mode, the sim counter is reset and the system clocks are disabled. an interrupt request from a module can cause an exit from stop mode. stacking for interrupts begins after the selected stop recovery time has elapsed. reset or break also causes an exit from stop mode. the sim disables the oscillator signals (busclkx2 and busclkx4) in stop mode, stopping the cpu and peripherals. if osceninstop is set, busclkx4 will remain running in stop and can be used to run the pwu. stop recovery time is selectable using the ssrec bit in the configuration register 1 (config1). if ssrec is set, stop recovery is reduced from the normal delay of 4096 busclkx4 cycles down to 32. this is ideal for the internal oscillator, rc oscillator, and external oscillator options which do not require long start-up times from stop mode. note external crystal applications should use the full stop recovery time by clearing the ssrec bit. $6e0c $6e0b $00ff $00fe $00fd $00fc $a6 $a6 $01 $0b $6e $a6 address bus data bus exitstopwait note: exitstopwait = rst pin or cpu interrupt address bus data bus rst (1) $a6 $a6 $6e0b rst vct h rst vct l $a6 busclkx4 32 cycles 32 cycles 1. rst is only available if the rsten bit in the config2 register is set.
system integration module (sim) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 166 freescale semiconductor the sim counter is held in reset from the execution of the stop instruction until the beginning of stop recovery. it is then used to time the recovery period. figure 14-17 shows stop mode entry timing and figure 14-18 shows the stop mode recovery time from interrupt or break note to minimize stop current, all pins configured as inputs should be driven to a logic 1 or logic 0. figure 14-17. stop mode entry timing figure 14-18. stop mode recovery from interrupt 14.8 sim registers the sim has three memory mapped registers. table 14-4 shows the mapping of these registers. table 14-4. sim registers address register access mode $fe00 bsr user $fe01 srsr user $fe03 bfcr user stop addr + 1 same same address bus data bus previous data next opcode same stop addr same r/ w cpustop note: previous data can be operand data or the stop opcode, depending on the last instruction. busclkx4 interrupt address bus stop + 2 stop + 2 sp sp ?1 sp ?2 sp ?3 stop +1 stop recovery period
sim registers mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 167 14.8.1 sim reset status register the srsr register contains flags that show the source of the last reset. the status register will automatically clear after reading srsr. a power-on reset sets the por bit and clears all other bits in the register. all other reset sources set the individual flag bits but do not clear the register. more than one reset source can be flagged at any time depending on the conditions at the time of the internal or external reset. for example, the por and lvi bit can both be set if the power supply has a slow rise time. por ?power-on reset bit 1 = last reset caused by por circuit 0 = read of srsr pin ?external reset bit 1 = last reset caused by external reset pin ( rst) 0 = por or read of srsr cop ?computer operating properly reset bit 1 = last reset caused by cop counter 0 = por or read of srsr ilop ?illegal opcode reset bit 1 = last reset caused by an illegal opcode 0 = por or read of srsr ilad ?illegal address reset bit (illegal attempt to fetch an opcode from an unimplemented address) 1 = last reset caused by an opcode fetch from an illegal address 0 = por or read of srsr modrst ?monitor mode entry module reset bit 1 = last reset caused by monitor mode entry when vector locations $fffe and $ffff are $ff after por while irq v tst 0 = por or read of srsr lvi ?low voltage inhibit reset bit 1 = last reset caused by lvi circuit 0 = por or read of srsr bit 7654321bit 0 read: por pin cop ilop ilad modrst lvi 0 write: por: 10000000 = unimplemented figure 14-19. sim reset status register (srsr)
system integration module (sim) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 168 freescale semiconductor 14.8.2 break flag control register the break control register (bfcr) contains a bit that enables software to clear status bits while the mcu is in a break state. bcfe ?break clear flag enable bit this read/write bit enables software to clear status bits by accessing status registers while the mcu is in a break state. to clear status bits during the break state, the bcfe bit must be set. 1 = status bits clearable during break 0 = status bits not clearable during break bit 7654321bit 0 read: bcfe rrrrrrr write: reset: 0 r = reserved figure 14-20. break flag control register (bfcr)
mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 169 chapter 15 serial peripheral interface (spi) module 15.1 introduction this section describes the serial peripheral interface (spi) module, which allows full-duplex, synchronous, serial communications with peripheral devices. the spi shares its pins with general-purpose input/output (i/o) port pins. see figure 15-1 for port location of these shared pins. 15.2 features features of the spi module include: full-duplex operation master and slave modes double-buffered operation with separate transmit and receive registers four master mode frequencies (maximum = bus frequency 2) maximum slave mode frequency = bus frequency serial clock with programmable polarity and phase two separately enabled interrupts: sprf (spi receiver full) spte (spi transmitter empty) mode fault error flag with interrupt capability overflow error flag with interrupt capability programmable wired-or mode 15.3 functional description the spi module allows full-duplex, synchronous, serial communication between the mcu and peripheral devices, including other mcus. software can poll the spi status flags or spi operation can be interrupt driven. the following paragraphs describe the operation of the spi module.
serial peripheral interface (spi) module mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 170 freescale semiconductor figure 15-1. block diagram highlighting spi block and pins all port pins can be configured with internal pullup ptc not available on 16-pin devices (see note in 11.1 introduction) ptd not available on 16-pin or 20-pin devices (see note in 11.1 introduction) pta0/t1ch0/ad0/kbi0 pta1/t1ch1/ad1/kbi1 pta2/ irq/kbi2/t1clk pta3/ rst/kbi3 pta4/osc2/ad2/kbi4 pta5/osc1/ad3/kbi5 4-channel 16-bit timer module keyboard interrupt module single interrupt module periodic wakeup low-voltage inhibit cop module 10-channel 10-bit adc enhanced serial ptb0/spsck/ad4 ptb ddrb m68hc08 cpu pta ddra ptb1/mosi/t2ch1/ad5 ptb2/miso/t2ch0/ad6 ptb3/ ss/t2clk/ad7 ptb4/rxd/t2ch0/ad8 ptb5/txd/t2ch1/ad9 ptb6/t1ch2 ptb7/t1ch3 power supply v dd v ss clock generator communications interface module module serial peripheral interface 16,384 bytes mc68hc908qc16 8192 bytes mc68hc908qc8 512 bytes mc68hc908qc16 384 bytes mc68hc908qc8 break module monitor rom 2-channel 16-bit timer module ptc0 ptc1 ptc2 ptc3 ptc ddrc ptd0 ptd ddrd ptd1 ptd2 ptd3 ptd4 ptd5 ptd6 ptd7 mc68hc908qc4 user ram user flash 4096 bytes 384 bytes mc68hc908qc4
functional description mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 171 figure 15-2. spi module block diagram transmitter interrupt request receiver/error interrupt request 76543210 spr1 spmstr transmit data register shift register spr0 clock select 2 clock divider 8 32 128 clock logic cpha cpol spi sprie spe spwom sprf spte ovrf m s pin control logic receive data register sptie spe internal bus busclk modfen errie control modf spmstr mosi miso spsck ss
serial peripheral interface (spi) module mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 172 freescale semiconductor 15.3.1 master mode the spi operates in master mode when the spi master bit, spmstr, is set. note in a multi-spi system, configure the spi modules as master or slave before enabling them. enable the master spi before enabling the slave spi. disable the slave spi before disabling the master spi. see 15.8.1 spi control register. only a master spi module can initiate transmissions. software begins the transmission from a master spi module by writing to the transmit data register. if the shift register is empty, the byte immediately transfers to the shift register, setting the spi transmitter empty bit, spte. the byte begins shifting out on the mosi pin under the control of the serial clock. see figure 15-3 . figure 15-3. full-duplex master-slave connections the spr1 and spr0 bits control the baud rate generator and determine the speed of the shift register. (see 15.8.2 spi status and control register.) through the spsck pin, the baud rate generator of the master also controls the shift register of the slave peripheral. while the byte shifts out on the mosi pin of the master, another byte shifts in from the slave on the master? miso pin. the transmission ends when the receiver full bit, sprf, becomes set. at the same time that sprf becomes set, the byte from the slave transfers to the receive data register. in normal operation, sprf signals the end of a transmission. software clears sprf by reading the spi status and control register (spscr) with sprf set and then reading the spi data register (spdr). writing to spdr clears spte. 15.3.2 slave mode the spi operates in slave mode when spmstr is clear. in slave mode, the spsck pin is the input for the serial clock from the master mcu. before a data transmission occurs, the ss pin of the slave spi must be low. ss must remain low until the transmission is complete. see 15.3.6.2 mode fault error. in a slave spi module, data enters the shift register under the control of the serial clock from the master spi module. after a byte enters the shift register of a slave spi, it transfers to the receive data register, and the sprf bit is set. to prevent an overflow condition, slave software then must read the receive data register before another full byte enters the shift register. shift register shift register baud rate generator master mcu slave mcu v dd mosi mosi miso miso spsck spsck ss ss
functional description mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 173 the maximum frequency of the spsck for an spi configured as a slave is the bus clock speed (which is twice as fast as the fastest master spsck clock that can be generated). the frequency of the spsck for an spi configured as a slave does not have to correspond to any spi baud rate. the baud rate only controls the speed of the spsck generated by an spi configured as a master. therefore, the frequency of the spsck for an spi configured as a slave can be any frequency less than or equal to the bus speed. when the master spi starts a transmission, the data in the slave shift register begins shifting out on the miso pin. the slave can load its shift register with a new byte for the next transmission by writing to its transmit data register. the slave must write to its transmit data register at least one bus cycle before the master starts the next transmission. otherwise, the byte already in the slave shift register shifts out on the miso pin. data written to the slave shift register during a transmission remains in a buffer until the end of the transmission. when the clock phase bit (cpha) is set, the first edge of spsck starts a transmission. when cpha is clear, the falling edge of ss starts a transmission. see 15.3.3 transmission formats. note spsck must be in the proper idle state before the slave is enabled to prevent spsck from appearing as a clock edge. 15.3.3 transmission formats during an spi transmission, data is simultaneously transmitted (shifted out serially) and received (shifted in serially). a serial clock synchronizes shifting and sampling on the two serial data lines. a slave select line allows selection of an individual slave spi device; slave devices that are not selected do not interfere with spi bus activities. on a master spi device, the slave select line can optionally be used to indicate multiple-master bus contention. 15.3.3.1 clock phase and polarity controls software can select any of four combinations of serial clock (spsck) phase and polarity using two bits in the spi control register (spcr). the clock polarity is specified by the cpol control bit, which selects an active high or low clock and has no significant effect on the transmission format. the clock phase (cpha) control bit selects one of two fundamentally different transmission formats. the clock phase and polarity should be identical for the master spi device and the communicating slave device. in some cases, the phase and polarity are changed between transmissions to allow a master device to communicate with peripheral slaves having different requirements. note before writing to the cpol bit or the cpha bit, disable the spi by clearing the spi enable bit (spe). 15.3.3.2 transmission format when cpha = 0 figure 15-4 shows an spi transmission in which cpha = 0. the figure should not be used as a replacement for data sheet parametric information. two waveforms are shown for spsck: one for cpol = 0 and another for cpol = 1. the diagram may be interpreted as a master or slave timing diagram because the serial clock (spsck), master in/slave out (miso), and master out/slave in (mosi) pins are directly connected between the master and the slave. the miso signal is the output from the slave, and the mosi signal is the output from the master. the ss line is the slave select input to the slave. the slave spi drives its miso output only when its slave select
serial peripheral interface (spi) module mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 174 freescale semiconductor input ( ss) is low, so that only the selected slave drives to the master. the ss pin of the master is not shown but is assumed to be inactive. the ss pin of the master must be high or must be reconfigured as general-purpose i/o not affecting the spi. (see 15.3.6.2 mode fault error .) when cpha = 0, the first spsck edge is the msb capture strobe. therefore, the slave must begin driving its data before the first spsck edge, and a falling edge on the ss pin is used to start the slave data transmission. the slave? ss pin must be toggled back to high and then low again between each byte transmitted as shown in figure 15-5 . when cpha = 0 for a slave, the falling edge of ss indicates the beginning of the transmission. this causes the spi to leave its idle state and begin driving the miso pin with the msb of its data. after the transmission begins, no new data is allowed into the shift register from the transmit data register. therefore, the spi data register of the slave must be loaded with transmit data before the falling edge of ss. any data written after the falling edge is stored in the transmit data register and transferred to the shift register after the current transmission. figure 15-4. transmission format (cpha = 0) figure 15-5. cpha/ ss timing 15.3.3.3 transmission format when cpha = 1 figure 15-6 shows an spi transmission in which cpha = 1. the figure should not be used as a replacement for data sheet parametric information. two waveforms are shown for spsck: one for cpol = 0 and another for cpol = 1. the diagram may be interpreted as a master or slave timing diagram because the serial clock (spsck), master in/slave out (miso), and master out/slave in (mosi) pins are directly connected between the master and the slave. the miso signal is the output from the slave, and the mosi signal is the output from the master. the ss line is the slave select input to the slave. the slave spi drives its miso output only when its slave select input ( ss) is low, so that only the selected slave drives to the master. the ss pin of the master is not shown but is assumed to be inactive. the ss bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 lsb msb bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 lsb msb 12345678 spsck cycle # for reference spsck; cpol = 0 spsck; cpol =1 mosi from master miso from slave ss; to slave capture strobe byte 1 byte 3 miso/mosi byte 2 master ss slave ss cpha = 0 slave ss cpha = 1
functional description mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 175 pin of the master must be high or must be reconfigured as general-purpose i/o not affecting the spi. (see 15.3.6.2 mode fault error .) when cpha = 1, the master begins driving its mosi pin on the first spsck edge. therefore, the slave uses the first spsck edge as a start transmission signal. the ss pin can remain low between transmissions. this format may be preferable in systems having only one master and only one slave driving the miso data line. when cpha = 1 for a slave, the first edge of the spsck indicates the beginning of the transmission. this causes the spi to leave its idle state and begin driving the miso pin with the msb of its data. after the transmission begins, no new data is allowed into the shift register from the transmit data register. therefore, the spi data register of the slave must be loaded with transmit data before the first edge of spsck. any data written after the first edge is stored in the transmit data register and transferred to the shift register after the current transmission. figure 15-6. transmission format (cpha = 1) 15.3.3.4 transmission initiation latency when the spi is configured as a master (spmstr = 1), writing to the spdr starts a transmission. cpha has no effect on the delay to the start of the transmission, but it does affect the initial state of the spsck signal. when cpha = 0, the spsck signal remains inactive for the first half of the first spsck cycle. when cpha = 1, the first spsck cycle begins with an edge on the spsck line from its inactive to its active level. the spi clock rate (selected by spr1:spr0) affects the delay from the write to spdr and the start of the spi transmission. (see figure 15-7 .) the internal spi clock in the master is a free-running derivative of the internal mcu clock. to conserve power, it is enabled only when both the spe and spmstr bits are set. because the spi clock is free-running, it is uncertain where the write to the spdr occurs relative to the slower spsck. this uncertainty causes the variation in the initiation delay shown in figure 15-7 . this delay is no longer than a single spi bit time. that is, the maximum delay is two mcu bus cycles for div2, eight mcu bus cycles for div8, 32 mcu bus cycles for div32, and 128 mcu bus cycles for div128. bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 lsb msb bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 lsb msb 12345678 spsck cycle # for reference spsck; cpol = 0 spsck; cpol =1 mosi from master miso from slave ss; to slave capture strobe
serial peripheral interface (spi) module mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 176 freescale semiconductor figure 15-7. transmission start delay (master) write to spdr initiation delay bus mosi spsck cpha = 1 spsck cpha = 0 spsck cycle number msb bit 6 12 clock write to spdr earliest latest spsck = bus clock 2; earliest latest 2 possible start points spsck = bus clock 8; 8 possible start points earliest latest spsck = bus clock 32; 32 possible start points earliest latest spsck = bus clock 128; 128 possible start points write to spdr write to spdr write to spdr bus clock bit 5 3 bus clock bus clock bus clock initiation delay from write spdr to transfer begin
functional description mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 177 15.3.4 queuing transmission data the double-buffered transmit data register allows a data byte to be queued and transmitted. for an spi configured as a master, a queued data byte is transmitted immediately after the previous transmission has completed. the spi transmitter empty flag (spte) indicates when the transmit data buffer is ready to accept new data. write to the transmit data register only when the spte bit is high. figure 15-8 shows the timing associated with doing back-to-back transmissions with the spi (spsck has cpha: cpol = 1:0). figure 15-8. sprf/spte interrupt timing the transmit data buffer allows back-to-back transmissions without the slave precisely timing its writes between transmissions as in a system with a single data buffer. also, if no new data is written to the data buffer, the last value contained in the shift register is the next data word to be transmitted. for an idle master or idle slave that has no data loaded into its transmit buffer, the spte is set again no more than two bus cycles after the transmit buffer empties into the shift register. this allows the user to queue up a 16-bit value to send. for an already active slave, the load of the shift register cannot occur until the transmission is completed. this implies that a back-to-back write to the transmit data register is not possible. spte indicates when the next write can occur. bit 3 mosi spsck spte write to spdr 1 write byte 2 to spdr, queueing byte 2 write byte 1 to spdr, clearing spte bit. byte 1 transfers from transmit data 3 1 2 2 3 5 register to shift register, setting spte bit. sprf read spscr msb bit 6 bit 5 bit 4 bit 2 bit 1 lsb msb bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 lsb msb bit 6 byte 2 transfers from transmit data write byte 3 to spdr, queueing byte byte 3 transfers from transmit data 5 8 10 8 10 4 first incoming byte transfers from shift 6 read spscr with sprf bit set. 4 6 9 second incoming byte transfers from shift 9 11 and clearing spte bit. register to shift register, setting spte bit. register to receive data register, setting sprf bit. 3 and clearing spte bit. register to shift register, setting spte bit. register to receive data register, setting sprf bit. 12 read spdr, clearing sprf bit. bit 5 bit 4 byte 1 byte 2 byte 3 7 12 read spdr 7 read spdr, clearing sprf bit. 11 read spscr with sprf bit set. cpha:cpol = 1:0
serial peripheral interface (spi) module mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 178 freescale semiconductor 15.3.5 resetting the spi any system reset completely resets the spi. partial resets occur whenever the spi enable bit (spe) is 0. whenever spe is 0, the following occurs: the spte flag is set. any transmission currently in progress is aborted. the shift register is cleared. the spi state counter is cleared, making it ready for a new complete transmission. all the spi pins revert back to being general-purpose i/o. these items are reset only by a system reset: all control bits in the spcr register all control bits in the spscr register (modfen, errie, spr1, and spr0) the status flags sprf, ovrf, and modf by not resetting the control bits when spe is low, the user can clear spe between transmissions without having to set all control bits again when spe is set high for the next transmission. by not resetting the sprf, ovrf, and modf flags, the user can still service these interrupts after the spi has been disabled. the user can disable the spi by writing 0 to the spe bit. the spi can also be disabled by a mode fault occurring in an spi that was configured as a master with the modfen bit set. 15.3.6 error conditions the following flags signal spi error conditions: overflow (ovrf) ?failing to read the spi data register before the next full byte enters the shift register sets the ovrf bit. the new byte does not transfer to the receive data register, and the unread byte still can be read. ovrf is in the spi status and control register. mode fault error (modf) ?the modf bit indicates that the voltage on the slave select pin ( ss) is inconsistent with the mode of the spi. modf is in the spi status and control register. 15.3.6.1 overflow error the overflow flag (ovrf) becomes set if the receive data register still has unread data from a previous transmission when the capture strobe of bit 1 of the next transmission occurs. the bit 1 capture strobe occurs in the middle of spsck cycle 7 (see figure 15-4 and figure 15-6 .) if an overflow occurs, all data received after the overflow and before the ovrf bit is cleared does not transfer to the receive data register and does not set the spi receiver full bit (sprf). the unread data that transferred to the receive data register before the overflow occurred can still be read. therefore, an overflow error always indicates the loss of data. clear the overflow flag by reading the spi status and control register and then reading the spi data register. ovrf generates a receiver/error interrupt request if the error interrupt enable bit (errie) is also set. the sprf, modf, and ovrf interrupts share the same interrupt vector (see figure 15-11 .) it is not possible to enable modf or ovrf individually to generate a receiver/error interrupt request. however, leaving modfen low prevents modf from being set. if the sprf interrupt is enabled and the ovrf interrupt is not, watch for an overflow condition. figure 15-9 shows how it is possible to miss an overflow. the first part of figure 15-9 shows how it is possible to read the spscr and spdr to clear the sprf without problems. however, as illustrated by
functional description mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 179 the second transmission example, the ovrf bit can be set in between the time that spscr and spdr are read. in this case, an overflow can be missed easily. because no more sprf interrupts can be generated until this ovrf is serviced, it is not obvious that bytes are being lost as more transmissions are completed. to prevent this, either enable the ovrf interrupt or do another read of the spscr following the read of the spdr. this ensures that the ovrf was not set before the sprf was cleared and that future transmissions can set the sprf bit. figure 15-10 illustrates this process. generally, to avoid this second spscr read, enable ovrf by setting the errie bit. figure 15-9. missed read of overflow condition figure 15-10. clearing sprf when ovrf interrupt is not enabled read read ovrf sprf byte 1 byte 2 byte 3 byte 4 byte 1 sets sprf bit. read spscr with sprf bit set read byte 1 in spdr, byte 2 sets sprf bit. read spscr with sprf bit set byte 3 sets ovrf bit. byte 3 is lost. read byte 2 in spdr, clearing sprf bit, byte 4 fails to set sprf bit because 1 1 2 3 4 5 6 7 8 2 3 4 5 6 7 8 clearing sprf bit. but not ovrf bit. ovrf bit is not cleared. byte 4 is lost. and ovrf bit clear. and ovrf bit clear. spscr spdr read read ovrf sprf byte 1 byte 2 byte 3 byte 4 1 byte 1 sets sprf bit. read spscr with sprf bit set read byte 1 in spdr, read spscr again to check ovrf bit. byte 2 sets sprf bit. read spscr with sprf bit set byte 3 sets ovrf bit. byte 3 is lost. read byte 2 in spdr, clearing sprf bit. read spscr again to check ovrf bit. read byte 2 spdr, clearing ovrf bit. byte 4 sets sprf bit. read spscr. read byte 4 in spdr, clearing sprf bit. read spscr again to check ovrf bit. 1 2 3 clearing sprf bit. 4 5 6 7 8 9 10 11 12 13 14 2 3 4 5 6 7 8 9 10 11 12 13 14 spi receive complete and ovrf bit clear. and ovrf bit clear. spscr spdr
serial peripheral interface (spi) module mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 180 freescale semiconductor 15.3.6.2 mode fault error setting spmstr selects master mode and configures the spsck and mosi pins as outputs and the miso pin as an input. clearing spmstr selects slave mode and configures the spsck and mosi pins as inputs and the miso pin as an output. the mode fault bit, modf, becomes set any time the state of the slave select pin, ss, is inconsistent with the mode selected by spmstr. to prevent spi pin contention and damage to the mcu, a mode fault error occurs if: the ss pin of a slave spi goes high during a transmission the ss pin of a master spi goes low at any time for the modf flag to be set, the mode fault error enable bit (modfen) must be set. clearing the modfen bit does not clear the modf flag but does prevent modf from being set again after modf is cleared. modf generates a receiver/error interrupt request if the error interrupt enable bit (errie) is also set. the sprf, modf, and ovrf interrupts share the same interrupt vector. (see figure 15-11 .) it is not possible to enable modf or ovrf individually to generate a receiver/error interrupt request. however, leaving modfen low prevents modf from being set. in a master spi with the mode fault enable bit (modfen) set, the mode fault flag (modf) is set if ss goes low. a mode fault in a master spi causes the following events to occur: if errie = 1, the spi generates an spi receiver/error interrupt request. the spe bit is cleared. the spte bit is set. the spi state counter is cleared. the data direction register of the shared i/o port regains control of port drivers. note to prevent bus contention with another master spi after a mode fault error, clear all spi bits of the data direction register of the shared i/o port before enabling the spi. when configured as a slave (spmstr = 0), the modf flag is set if ss goes high during a transmission. when cpha = 0, a transmission begins when ss goes low and ends after the incoming spsck goes to its idle level following the shift of the eighth data bit. when cpha = 1, the transmission begins when the spsck leaves its idle level and ss is already low. the transmission continues until the spsck returns to its idle level following the shift of the last data bit. see 15.3.3 transmission formats. note setting the modf flag does not clear the spmstr bit. spmstr has no function when spe = 0. reading spmstr when modf = 1 shows the difference between a modf occurring when the spi is a master and when it is a slave. when cpha = 0, a modf occurs if a slave is selected ( ss is low) and later unselected ( ss is high) even if no spsck is sent to that slave. this happens because ss low indicates the start of the transmission (miso driven out with the value of msb) for cpha = 0. when cpha = 1, a slave can be selected and then later unselected with no transmission occurring. therefore, modf does not occur because a transmission was never begun.
interrupts mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 181 in a slave spi (mstr = 0), modf generates an spi receiver/error interrupt request if the errie bit is set. the modf bit does not clear the spe bit or reset the spi in any way. software can abort the spi transmission by clearing the spe bit of the slave. note a high on the ss pin of a slave spi puts the miso pin in a high impedance state. also, the slave spi ignores all incoming spsck clocks, even if it was already in the middle of a transmission. to clear the modf flag, read the spscr with the modf bit set and then write to the spcr register. this entire clearing mechanism must occur with no modf condition existing or else the flag is not cleared. 15.4 interrupts four spi status flags can be enabled to generate interrupt requests. see table 15-1 . reading the spi status and control register with sprf set and then reading the receive data register clears sprf. the clearing mechanism for the spte flag is requires only a write to the transmit data register. the spi transmitter interrupt enable bit (sptie) enables the spte flag to generate transmitter interrupt requests, provided that the spi is enabled (spe = 1). the spi receiver interrupt enable bit (sprie) enables sprf to generate receiver interrupt requests, regardless of the state of spe. see figure 15-11 . figure 15-11. spi interrupt request generation table 15-1. spi interrupts flag request spte tr ansmitter empty spi transmitter interrupt request (sptie = 1, spe = 1) sprf receiver full spi receiver interrupt request (sprie = 1) ovrf over?w spi receiver/error interrupt request (errie = 1) modf mode fault spi receiver/error interrupt request (errie = 1) spte sptie sprf sprie spe interrupt request interrupt request spi transmitter spi receiver/error errie modf ovrf
serial peripheral interface (spi) module mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 182 freescale semiconductor the error interrupt enable bit (errie) enables both the modf and ovrf bits to generate a receiver/error interrupt request. the mode fault enable bit (modfen) can prevent the modf flag from being set so that only the ovrf bit is enabled by the errie bit to generate receiver/error interrupt requests. the following sources in the spi status and control register can generate interrupt requests: spi receiver full bit (sprf) sprf becomes set every time a byte transfers from the shift register to the receive data register. if the spi receiver interrupt enable bit, sprie, is also set, sprf generates an spi receiver/error interrupt request. spi transmitter empty bit (spte) ?spte becomes set every time a byte transfers from the transmit data register to the shift register. if the spi transmit interrupt enable bit, sptie, is also set, spte generates an spte interrupt request. 15.5 low-power modes the wait and stop instructions put the mcu in low power-consumption standby modes. 15.5.1 wait mode the spi module remains active after the execution of a wait instruction. in wait mode the spi module registers are not accessible by the cpu. any enabled interrupt request from the spi module can bring the mcu out of wait mode. if spi module functions are not required during wait mode, reduce power consumption by disabling the spi module before executing the wait instruction. to exit wait mode when an overflow condition occurs, enable the ovrf bit to generate interrupt requests by setting the error interrupt enable bit (errie). see 15.4 interrupts. 15.5.2 stop mode the spi module is inactive after the execution of a stop instruction. the stop instruction does not affect register conditions. spi operation resumes after an external interrupt. if stop mode is exited by reset, any transfer in progress is aborted, and the spi is reset. 15.6 spi during break interrupts the system integration module (sim) controls whether status bits in other modules can be cleared during the break state. the bcfe bit in the break flag control register (bfcr) enables software to clear status bits during the break state. see bfcr in the sim section of this data sheet. to allow software to clear status bits during a break interrupt, write a 1 to bcfe. if a status bit is cleared during the break state, it remains cleared when the mcu exits the break state. to protect status bits during the break state, write a 0 to bcfe. with bcfe cleared (its default state), software can read and write registers during the break state without affecting status bits. some status bits have a two-step read/write clearing procedure. if software does the first step on such a bit before the break, the bit cannot change during the break state as long as bcfe is cleared. after the break, doing the second step clears the status bit.
i/o signals mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 183 15.7 i/o signals the spi module can share its pins with the general-purpose i/o pins. see figure 15-1 for the port pins that are shared. the spi module has four i/o pins: miso ?master input/slave output mosi ?master output/slave input spsck ?serial clock ss ?slave select 15.7.1 miso (master in/slave out) miso is one of the two spi module pins that transmits serial data. in full duplex operation, the miso pin of the master spi module is connected to the miso pin of the slave spi module. the master spi simultaneously receives data on its miso pin and transmits data from its mosi pin. slave output data on the miso pin is enabled only when the spi is configured as a slave. the spi is configured as a slave when its spmstr bit is 0 and its ss pin is low. to support a multiple-slave system, a high on the ss pin puts the miso pin in a high-impedance state. when enabled, the spi controls data direction of the miso pin regardless of the state of the data direction register of the shared i/o port. 15.7.2 mosi (master out/slave in) mosi is one of the two spi module pins that transmits serial data. in full-duplex operation, the mosi pin of the master spi module is connected to the mosi pin of the slave spi module. the master spi simultaneously transmits data from its mosi pin and receives data on its miso pin. when enabled, the spi controls data direction of the mosi pin regardless of the state of the data direction register of the shared i/o port. 15.7.3 spsck (serial clock) the serial clock synchronizes data transmission between master and slave devices. in a master mcu, the spsck pin is the clock output. in a slave mcu, the spsck pin is the clock input. in full-duplex operation, the master and slave mcus exchange a byte of data in eight serial clock cycles. when enabled, the spi controls data direction of the spsck pin regardless of the state of the data direction register of the shared i/o port. 15.7.4 ss (slave select) the ss pin has various functions depending on the current state of the spi. for an spi configured as a slave, ss is used to select a slave. for cpha = 0, the ss is used to define the start of a transmission. (see 15.3.3 transmission formats.) because it is used to indicate the start of a transmission, ss must be toggled high and low between each byte transmitted for the cpha = 0 format. however, it can remain low between transmissions for the cpha = 1 format. see figure 15-12 . when an spi is configured as a slave, the ss pin is always configured as an input. it cannot be used as a general-purpose i/o regardless of the state of the modfen control bit. however, the modfen bit can still prevent the state of ss from creating a modf error. see 15.8.2 spi status and control register.
serial peripheral interface (spi) module mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 184 freescale semiconductor figure 15-12. cpha/ ss timing note a high on the ss pin of a slave spi puts the miso pin in a high-impedance state. the slave spi ignores all incoming spsck clocks, even if it was already in the middle of a transmission. when an spi is configured as a master, the ss input can be used in conjunction with the modf flag to prevent multiple masters from driving mosi and spsck. (see 15.3.6.2 mode fault error .) for the state of the ss pin to set the modf flag, the modfen bit in the spsck register must be set. if the modfen bit is 0 for an spi master, the ss pin can be used as a general-purpose i/o under the control of the data direction register of the shared i/o port. when modfen is 1, it is an input-only pin to the spi regardless of the state of the data direction register of the shared i/o port. user software can read the state of the ss pin by configuring the appropriate pin as an input and reading the port data register. see table 15-2. 15.8 registers the following registers allow the user to control and monitor spi operation: spi control register (spcr) spi status and control register (spscr) spi data register (spdr) 15.8.1 spi control register the spi control register: enables spi module interrupt requests configures the spi module as master or slave selects serial clock polarity and phase configures the spsck, mosi, and miso pins as open-drain outputs enables the spi module table 15-2. spi con?uration spe spmstr modfen spi configuration function of ss pin 0 x (1) 1. x = don? care x not enabled general-purpose i/o; ss ignored by spi 1 0 x slave input-only to spi 1 1 0 master without modf general-purpose i/o; ss ignored by spi 1 1 1 master with modf input-only to spi byte 1 byte 3 miso/mosi byte 2 master ss slave ss cpha = 0 slave ss cpha = 1
registers mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 185 sprie ?spi receiver interrupt enable bit this read/write bit enables interrupt requests generated by the sprf bit. the sprf bit is set when a byte transfers from the shift register to the receive data register. 1 = sprf interrupt requests enabled 0 = sprf interrupt requests disabled spmstr ?spi master bit this read/write bit selects master mode operation or slave mode operation. 1 = master mode 0 = slave mode cpol ?clock polarity bit this read/write bit determines the logic state of the spsck pin between transmissions. (see figure 15-4 and figure 15-6 .) to transmit data between spi modules, the spi modules must have identical cpol values. cpha ?clock phase bit this read/write bit controls the timing relationship between the serial clock and spi data. (see figure 15-4 and figure 15-6 .) to transmit data between spi modules, the spi modules must have identical cpha values. when cpha = 0, the ss pin of the slave spi module must be high between bytes. (see figure 15-12 .) spwom ?spi wired-or mode bit this read/write bit configures pins spsck, mosi, and miso so that these pins become open-drain outputs. 1 = wired-or spsck, mosi, and miso pins 0 = normal push-pull spsck, mosi, and miso pins spe ?spi enable this read/write bit enables the spi module. clearing spe causes a partial reset of the spi. (see 15.3.5 resetting the spi.) 1 = spi module enabled 0 = spi module disabled sptie?spi transmit interrupt enable this read/write bit enables interrupt requests generated by the spte bit. spte is set when a byte transfers from the transmit data register to the shift register. 1 = spte interrupt requests enabled 0 = spte interrupt requests disabled bit 7654321bit 0 read: sprie r spmstr cpol cpha spwom spe sptie write: reset:00101000 r = reserved figure 15-13. spi control register (spcr)
serial peripheral interface (spi) module mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 186 freescale semiconductor 15.8.2 spi status and control register the spi status and control register contains flags to signal these conditions: receive data register full failure to clear sprf bit before next byte is received (overflow error) inconsistent logic level on ss pin (mode fault error) transmit data register empty the spi status and control register also contains bits that perform these functions: enable error interrupts enable mode fault error detection select master spi baud rate sprf ?spi receiver full bit this clearable, read-only flag is set each time a byte transfers from the shift register to the receive data register. sprf generates a interrupt request if the sprie bit in the spi control register is set also. during an sprf interrupt, user software can clear sprf by reading the spi status and control register with sprf set followed by a read of the spi data register. 1 = receive data register full 0 = receive data register not full errie ?error interrupt enable bit this read/write bit enables the modf and ovrf bits to generate interrupt requests. 1 = modf and ovrf can generate interrupt requests 0 = modf and ovrf cannot generate interrupt requests ovrf ?over?w bit this clearable, read-only flag is set if software does not read the byte in the receive data register before the next full byte enters the shift register. in an overflow condition, the byte already in the receive data register is unaffected, and the byte that shifted in last is lost. clear the ovrf bit by reading the spi status and control register with ovrf set and then reading the receive data register. 1 = overflow 0 = no overflow modf ?mode fault bit this clearable, read-only flag is set in a slave spi if the ss pin goes high during a transmission with modfen set. in a master spi, the modf flag is set if the ss pin goes low at any time with the modfen bit set. clear modf by reading the spi status and control register (spscr) with modf set and then writing to the spi control register (spcr). 1 = ss pin at inappropriate logic level 0 = ss pin at appropriate logic level bit 7654321bit 0 read: sprf errie ovrf modf spte modfen spr1 spr0 write: reset:00001000 = unimplemented figure 15-14. spi status and control register (spscr)
registers mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 187 spte ?spi transmitter empty bit this clearable, read-only flag is set each time the transmit data register transfers a byte into the shift register. spte generates an spte interrupt request if the sptie bit in the spi control register is also set. note do not write to the spi data register unless spte is high. during an spte interrupt, user software can clear spte by writing to the transmit data register. 1 = transmit data register empty 0 = transmit data register not empty modfen ?mode fault enable bit this read/write bit, when set, allows the modf flag to be set. if the modf flag is set, clearing modfen does not clear the modf flag. if the spi is enabled as a master and the modfen bit is 0, then the ss pin is available as a general-purpose i/o. if the modfen bit is 1, then this pin is not available as a general-purpose i/o. when the spi is enabled as a slave, the ss pin is not available as a general-purpose i/o regardless of the value of modfen. see 15.7.4 ss (slave select). if the modfen bit is 0, the level of the ss pin does not affect the operation of an enabled spi configured as a master. for an enabled spi configured as a slave, having modfen low only prevents the modf flag from being set. it does not affect any other part of spi operation. see 15.3.6.2 mode fault error. spr1 and spr0 ?spi baud rate select bits in master mode, these read/write bits select one of four baud rates as shown in table 15-3 . spr1 and spr0 have no effect in slave mode. use this formula to calculate the spi baud rate: table 15-3. spi master baud rate selection spr1 and spr0 baud rate divisor (bd) 00 2 01 8 10 32 11 128 baud rate = busclk bd
serial peripheral interface (spi) module mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 188 freescale semiconductor 15.8.3 spi data register the spi data register consists of the read-only receive data register and the write-only transmit data register. writing to the spi data register writes data into the transmit data register. reading the spi data register reads data from the receive data register. the transmit data and receive data registers are separate registers that can contain different values. see figure 15-2 . r7?0/t7?0 ?receive/transmit data bits note do not use read-modify-write instructions on the spi data register because the register read is not the same as the register written. bit 7654321bit 0 read: r7 r6 r5 r4 r3 r2 r1 r0 write: t7 t6 t5 t4 t3 t2 t1 t0 reset: unaffected by reset figure 15-15. spi data register (spdr)
mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 189 chapter 16 timer interface module (tim1) 16.1 introduction this section describes the timer interface module (tim1). the tim1 module is a 4-channel timer that provides a timing reference with input capture, output compare, and pulse-width-modulation functions. the tim1 module shares its pins with general-purpose input/output (i/o) port pins. see figure 16-1 for port location of these shared pins. 16.2 features features include the following: four input capture/output compare channels rising-edge, falling-edge, or any-edge input capture trigger set, clear, or toggle output compare action buffered and unbuffered output compare pulse-width modulation (pwm) signal generation programmable clock input 7-frequency internal bus clock prescaler selection external clock input pin if available, see figure 16-1 free-running or modulo up-count operation toggle any channel pin on overflow counter stop and reset bits 16.3 functional description figure 16-2 shows the structure of the tim1. the central component of the tim1 is the 16-bit counter that can operate as a free-running counter or a modulo up-counter. the counter provides the timing reference for the input capture and output compare functions. the tim1 counter modulo registers, t1modh:t1modl, control the modulo value of the counter. software can read the counter value, t1cnth:t1cntl, at any time without affecting the counting sequence. the four tim1 channels are programmable independently as input capture or output compare channels.
timer interface module (tim1) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 190 freescale semiconductor figure 16-1. block diagram highlighting tim1 block and pins all port pins can be configured with internal pullup ptc not available on 16-pin devices (see note in 11.1 introduction) ptd not available on 16-pin or 20-pin devices (see note in 11.1 introduction) pta0/t1ch0/ad0/kbi0 pta1/t1ch1/ad1/kbi1 pta2/ irq/kbi2/t1clk pta3/ rst/kbi3 pta4/osc2/ad2/kbi4 pta5/osc1/ad3/kbi5 4-channel 16-bit timer module keyboard interrupt module single interrupt module periodic wakeup low-voltage inhibit cop module 10-channel 10-bit adc enhanced serial ptb0/spsck/ad4 ptb ddrb m68hc08 cpu pta ddra ptb1/mosi/t2ch1/ad5 ptb2/miso/t2ch0/ad6 ptb3/ ss/t2clk/ad7 ptb4/rxd/t2ch0/ad8 ptb5/txd/t2ch1/ad9 ptb6/t1ch2 ptb7/t1ch3 power supply v dd v ss clock generator communications interface module module serial peripheral interface 16,384 bytes mc68hc908qc16 8192 bytes mc68hc908qc8 512 bytes mc68hc908qc16 384 bytes mc68hc908qc8 break module monitor rom 2-channel 16-bit timer module ptc0 ptc1 ptc2 ptc3 ptc ddrc ptd0 ptd ddrd ptd1 ptd2 ptd3 ptd4 ptd5 ptd6 ptd7 mc68hc908qc4 user ram user flash 4096 bytes 384 bytes mc68hc908qc4
functional description mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 191 figure 16-2. tim1 block diagram prescaler prescaler select 16-bit comparator ps2 ps1 ps0 16-bit comparator 16-bit latch ms0a els0b els0a tof toie 16-bit comparator 16-bit latch channel 0 channel 1 trst tstop tov0 ch0ie ch0f els1b els1a tov1 ch1ie ch1max ch1f ch0max ms0b internal bus ms1a internal bus clock interrupt logic port logic interrupt logic interrupt logic port logic (if available) 16-bit counter 16-bit comparator 16-bit latch ms2a els2b els2a 16-bit comparator 16-bit latch channel 2 channel 3 tov2 ch2ie ch2f els3b els3a tov3 ch3ie ch3max ch3f ch2max ms2b ms3a t1ch3 t1ch2 t1ch1 t1ch0 t1ch3h:t1ch3l t1ch2h:t1ch2l t1ch1h:t1ch1l t1ch0h:t1ch0l t1modh:t1modl t1cnth:t1cntl t1clk t1clk interrupt logic port logic interrupt logic port logic
timer interface module (tim1) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 192 freescale semiconductor 16.3.1 tim1 counter prescaler the tim1 clock source is one of the seven prescaler outputs or the external clock input pin, t1clk if available. the prescaler generates seven clock rates from the internal bus clock. the prescaler select bits, ps[2:0], in the tim1 status and control register (t1sc) select the clock source. 16.3.2 input capture with the input capture function, the tim1 can capture the time at which an external event occurs. when an active edge occurs on the pin of an input capture channel, the tim1 latches the contents of the counter into the tim1 channel registers, t1chxh:t1chxl. the polarity of the active edge is programmable. input captures can be enabled to generate interrupt requests. 16.3.3 output compare with the output compare function, the tim1 can generate a periodic pulse with a programmable polarity, duration, and frequency. when the counter reaches the value in the registers of an output compare channel, the tim1 can set, clear, or toggle the channel pin. output compares can be enabled to generate interrupt requests. 16.3.3.1 unbuffered output compare any output compare channel can generate unbuffered output compare pulses as described in 16.3.3 output compare . the pulses are unbuffered because changing the output compare value requires writing the new value over the old value currently in the tim1 channel registers. an unsynchronized write to the tim1 channel registers to change an output compare value could cause incorrect operation for up to two counter overflow periods. for example, writing a new value before the counter reaches the old value but after the counter reaches the new value prevents any compare during that counter overflow period. also, using a tim1 overflow interrupt routine to write a new, smaller output compare value may cause the compare to be missed. the tim1 may pass the new value before it is written. use the following methods to synchronize unbuffered changes in the output compare value on channel x: when changing to a smaller value, enable channel x output compare interrupts and write the new value in the output compare interrupt routine. the output compare interrupt occurs at the end of the current output compare pulse. the interrupt routine has until the end of the counter overflow period to write the new value. when changing to a larger output compare value, enable tim1 overflow interrupts and write the new value in the tim1 overflow interrupt routine. the tim1 overflow interrupt occurs at the end of the current counter overflow period. writing a larger value in an output compare interrupt routine (at the end of the current pulse) could cause two output compares to occur in the same counter overflow period. 16.3.3.2 buffered output compare channels 0 and 1 can be linked to form a buffered output compare channel whose output appears on the t1ch0 pin. the tim1 channel registers of the linked pair alternately control the output. setting the ms0b bit in tim1 channel 0 status and control register (t1sc0) links channel 0 and channel 1. the output compare value in the tim1 channel 0 registers initially controls the output on the t1ch0 pin. writing to the tim1 channel 1 registers enables the tim1 channel 1 registers to synchronously control the
functional description mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 193 output after the tim1 overflows. at each subsequent overflow, the tim1 channel registers (0 or 1) that control the output are the ones written to last. t1sc0 controls and monitors the buffered output compare function, and tim1 channel 1 status and control register (t1sc1) is unused. while the ms0b bit is set, the channel 1 pin, t1ch1, is available as a general-purpose i/o pin. channels 2 and 3 can be linked to form a buffered output compare channel whose output appears on the t1ch2 pin. the tim1 channel registers of the linked pair alternately control the output. setting the ms2b bit in tim1 channel 2 status and control register (t1sc2) links channel 2 and channel 3. the output compare value in the tim1 channel 2 registers initially controls the output on the t1ch2 pin. writing to the tim1 channel 3 registers enables the tim1 channel 3 registers to synchronously control the output after the tim1 overflows. at each subsequent overflow, the tim1 channel registers (2 or 3) that control the output are the ones written to last. t1sc2 controls and monitors the buffered output compare function, and tim1 channel 3 status and control register (t1sc3) is unused. while the ms2b bit is set, the channel 3 pin, t1ch3, is available as a general-purpose i/o pin. note in buffered output compare operation, do not write new output compare values to the currently active channel registers. user software should track the currently active channel to prevent writing a new value to the active channel. writing to the active channel registers is the same as generating unbuffered output compares. 16.3.4 pulse width modulation (pwm) by using the toggle-on-overflow feature with an output compare channel, the tim1 can generate a pwm signal. the value in the tim1 counter modulo registers determines the period of the pwm signal. the channel pin toggles when the counter reaches the value in the tim1 counter modulo registers. the time between overflows is the period of the pwm signal. as figure 16-3 shows, the output compare value in the tim1 channel registers determines the pulse width of the pwm signal. the time between overflow and output compare is the pulse width. program the tim1 to clear the channel pin on output compare if the polarity of the pwm pulse is 1 (elsxa = 0). program the tim1 to set the pin if the polarity of the pwm pulse is 0 (elsxa = 1). figure 16-3. pwm period and pulse width period pulse width overflow overflow overflow output compare output compare output compare polarity = 1 (elsxa = 0) polarity = 0 (elsxa = 1) t1chx t1chx
timer interface module (tim1) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 194 freescale semiconductor the value in the tim1 counter modulo registers and the selected prescaler output determines the frequency of the pwm output the frequency of an 8-bit pwm signal is variable in 256 increments. writing $00ff (255) to the tim1 counter modulo registers produces a pwm period of 256 times the internal bus clock period if the prescaler select value is 000. see 16.8.1 tim1 status and control register. the value in the tim1 channel registers determines the pulse width of the pwm output. the pulse width of an 8-bit pwm signal is variable in 256 increments. writing $0080 (128) to the tim1 channel registers produces a duty cycle of 128/256 or 50%. 16.3.4.1 unbuffered pwm signal generation any output compare channel can generate unbuffered pwm pulses as described in 16.3.4 pulse width modulation (pwm) . the pulses are unbuffered because changing the pulse width requires writing the new pulse width value over the old value currently in the tim1 channel registers. an unsynchronized write to the tim1 channel registers to change a pulse width value could cause incorrect operation for up to two pwm periods. for example, writing a new value before the counter reaches the old value but after the counter reaches the new value prevents any compare during that pwm period. also, using a tim1 overflow interrupt routine to write a new, smaller pulse width value may cause the compare to be missed. the tim1 may pass the new value before it is written to the timer channel (t1chxh:t1chxl). use the following methods to synchronize unbuffered changes in the pwm pulse width on channel x: when changing to a shorter pulse width, enable channel x output compare interrupts and write the new value in the output compare interrupt routine. the output compare interrupt occurs at the end of the current pulse. the interrupt routine has until the end of the pwm period to write the new value. when changing to a longer pulse width, enable tim1 overflow interrupts and write the new value in the tim1 overflow interrupt routine. the tim1 overflow interrupt occurs at the end of the current pwm period. writing a larger value in an output compare interrupt routine (at the end of the current pulse) could cause two output compares to occur in the same pwm period. note in pwm signal generation, do not program the pwm channel to toggle on output compare. toggling on output compare prevents reliable 0% duty cycle generation and removes the ability of the channel to self-correct in the event of software error or noise. toggling on output compare also can cause incorrect pwm signal generation when changing the pwm pulse width to a new, much larger value. 16.3.4.2 buffered pwm signal generation channels 0 and 1 can be linked to form a buffered pwm channel whose output appears on the t1ch0 pin. the tim1 channel registers of the linked pair alternately control the output. setting the ms0b bit in tim1 channel 0 status and control register (t1sc0) links channel 0 and channel 1. the tim1 channel 0 registers initially control the pulse width on the t1ch0 pin. writing to the tim1 channel 1 registers enables the tim1 channel 1 registers to synchronously control the pulse width at the beginning of the next pwm period. at each subsequent overflow, the tim1 channel registers (0 or 1) that control the pulse width are the ones written to last. t1sc0 controls and monitors the buffered pwm
functional description mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 195 function, and tim1 channel 1 status and control register (t1sc1) is unused. while the ms0b bit is set, the channel 1 pin, t1ch1, is available as a general-purpose i/o pin. channels 2 and 3 can be linked to form a buffered pwm channel whose output appears on the t1ch2 pin. the tim1 channel registers of the linked pair alternately control the output. setting the ms2b bit in tim1 channel 2 status and control register (t1sc2) links channel 2 and channel 3. the tim1 channel 2 registers initially control the pulse width on the t1ch2 pin. writing to the tim1 channel 3 registers enables the tim1 channel 3 registers to synchronously control the pulse width at the beginning of the next pwm period. at each subsequent overflow, the tim1 channel registers (2 or 3) that control the pulse width are the ones written to last. t1sc2 controls and monitors the buffered pwm function, and tim1 channel 3 status and control register (t1sc3) is unused. while the ms2b bit is set, the channel 3 pin, t1ch3, is available as a general-purpose i/o pin. note in buffered pwm signal generation, do not write new pulse width values to the currently active channel registers. user software should track the currently active channel to prevent writing a new value to the active channel. writing to the active channel registers is the same as generating unbuffered pwm signals. 16.3.4.3 pwm initialization to ensure correct operation when generating unbuffered or buffered pwm signals, use the following initialization procedure: 1. in the tim1 status and control register (t1sc): a. stop the counter by setting the tim1 stop bit, tstop. b. reset the counter and prescaler by setting the tim1 reset bit, trst. 2. in the tim1 counter modulo registers (t1modh:t1modl), write the value for the required pwm period. 3. in the tim1 channel x registers (t1chxh:t1chxl), write the value for the required pulse width. 4. in tim1 channel x status and control register (t1scx): a. write 0:1 (for unbuffered output compare or pwm signals) or 1:0 (for buffered output compare or pwm signals) to the mode select bits, msxb:msxa. see table 16-2 . b. write 1 to the toggle-on-overflow bit, tovx. c. write 1:0 (polarity 1 ?to clear output on compare) or 1:1 (polarity 0 ?to set output on compare) to the edge/level select bits, elsxb:elsxa. the output action on compare must force the output to the complement of the pulse width level. see table 16-2 . note in pwm signal generation, do not program the pwm channel to toggle on output compare. toggling on output compare prevents reliable 0% duty cycle generation and removes the ability of the channel to self-correct in the event of software error or noise. toggling on output compare can also cause incorrect pwm signal generation when changing the pwm pulse width to a new, much larger value. 5. in the tim1 status control register (t1sc), clear the tim1 stop bit, tstop.
timer interface module (tim1) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 196 freescale semiconductor setting ms0b links channels 0 and 1 and configures them for buffered pwm operation. the tim1 channel 0 registers (t1ch0h:t1ch0l) initially control the buffered pwm output. tim1 status control register 0 (t1sc0) controls and monitors the pwm signal from the linked channels. ms0b takes priority over ms0a. setting ms2b links channels 2 and 3 and configures them for buffered pwm operation. the tim1 channel 2 registers (t1ch2h:t1ch2l) initially control the buffered pwm output. tim1 status control register 2 (t1sc2) controls and monitors the pwm signal from the linked channels. ms2b takes priority over ms2a. clearing the toggle-on-overflow bit, tovx, inhibits output toggles on tim1 overflows. subsequent output compares try to force the output to a state it is already in and have no effect. the result is a 0% duty cycle output. setting the channel x maximum duty cycle bit (chxmax) and setting the tovx bit generates a 100% duty cycle output. see 16.8.4 tim1 channel status and control registers. 16.4 interrupts the following tim1 sources can generate interrupt requests: tim1 overflow flag (tof) ?the tof bit is set when the counter reaches the modulo value programmed in the tim1 counter modulo registers. the tim1 overflow interrupt enable bit, toie, enables tim1 overflow interrupt requests. tof and toie are in the t1sc register. tim1 channel flags (ch3f:ch0f) the chxf bit is set when an input capture or output compare occurs on channel x. channel x tim1 interrupt requests are controlled by the channel x interrupt enable bit, chxie. channel x tim1 interrupt requests are enabled when chxie =1. chxf and chxie are in the t1scx register. 16.5 low-power modes the wait and stop instructions put the mcu in low power-consumption standby modes. 16.5.1 wait mode the tim1 remains active after the execution of a wait instruction. in wait mode the tim1 registers are not accessible by the cpu. any enabled interrupt request from the tim1 can bring the mcu out of wait mode. if tim1 functions are not required during wait mode, reduce power consumption by stopping the tim1 before executing the wait instruction. 16.5.2 stop mode the tim1 module is inactive after the execution of a stop instruction. the stop instruction does not affect register conditions. tim1 operation resumes after an external interrupt. if stop mode is exited by reset, the tim1 is reset.
tim1 during break interrupts mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 197 16.6 tim1 during break interrupts a break interrupt stops the counter and inhibits input captures. the system integration module (sim) controls whether status bits in other modules can be cleared during the break state. the bcfe bit in the break flag control register (bfcr) enables software to clear status bits during the break state. see bfcr in the sim section of this data sheet. to allow software to clear status bits during a break interrupt, write a 1 to bcfe. if a status bit is cleared during the break state, it remains cleared when the mcu exits the break state. to protect status bits during the break state, write a 0 to bcfe. with bcfe cleared (its default state), software can read and write registers during the break state without affecting status bits. some status bits have a two-step read/write clearing procedure. if software does the first step on such a bit before the break, the bit cannot change during the break state as long as bcfe is cleared. after the break, doing the second step clears the status bit. 16.7 i/o signals the tim1 module can share its pins with the general-purpose i/o pins. see figure 16-1 for the port pins that are shared. 16.7.1 tim1 channel i/o pins (t1ch3:t1ch0) each channel i/o pin is programmable independently as an input capture pin or an output compare pin. t1ch0 and t1ch2 can be configured as buffered output compare or buffered pwm pins. 16.7.2 tim1 clock pin (t1clk) t1clk is an external clock input that can be the clock source for the counter instead of the prescaled internal bus clock. select the t1clk input by writing 1s to the three prescaler select bits, ps[2:0]. the timer interface module characteristics table in the electricals section. the maximum t1clk frequency is the least of 4 mhz or bus frequency 2. 16.8 registers the following registers control and monitor operation of the tim1: tim1 status and control register (t1sc) tim1 control registers (t1cnth:t1cntl) tim1 counter modulo registers (t1modh:t1modl) tim1 channel status and control registers (t1sc0 through t1sc3) tim1 channel registers (t1ch0h:t1ch0l through t1ch3h:t1ch3l) 16.8.1 tim1 status and control register the tim1 status and control register (t1sc) does the following: enables tim1 overflow interrupts flags tim1 overflows stops the counter resets the counter prescales the counter clock
timer interface module (tim1) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 198 freescale semiconductor tof ?tim1 over?w flag bit this read/write flag is set when the counter reaches the modulo value programmed in the tim1 counter modulo registers. clear tof by reading the t1sc register when tof is set and then writing a 0 to tof. if another tim1 overflow occurs before the clearing sequence is complete, then writing 0 to tof has no effect. therefore, a tof interrupt request cannot be lost due to inadvertent clearing of tof. writing a 1 to tof has no effect. 1 = counter has reached modulo value 0 = counter has not reached modulo value toie ?tim1 overflow interrupt enable bit this read/write bit enables tim1 overflow interrupts when the tof bit becomes set. 1 = tim1 overflow interrupts enabled 0 = tim1 overflow interrupts disabled tstop ?tim1 stop bit this read/write bit stops the counter. counting resumes when tstop is cleared. reset sets the tstop bit, stopping the counter until software clears the tstop bit. 1 = counter stopped 0 = counter active note do not set the tstop bit before entering wait mode if the tim1 is required to exit wait mode. also, when the tstop bit is set and the timer is configured for input capture operation, input captures are inhibited until the tstop bit is cleared. when using tstop to stop the timer counter, see if any timer flags are set. if a timer flag is set, it must be cleared by clearing tstop, then clearing the flag, then setting tstop again. trst ?tim1 reset bit setting this write-only bit resets the counter and the tim1 prescaler. setting trst has no effect on any other timer registers. counting resumes from $0000. trst is cleared automatically after the counter is reset and always reads as 0. 1 = prescaler and counter cleared 0 = no effect note setting the tstop and trst bits simultaneously stops the counter at a value of $0000. bit 7654321bit 0 read: tof toie tstop 00 ps2 ps1 ps0 write: 0 trst reset:00100000 = unimplemented figure 16-4. tim1 status and control register (t1sc)
registers mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 199 ps[2:0] ?prescaler select bits these read/write bits select one of the seven prescaler outputs as the input to the counter as table 16-1 shows. 16.8.2 tim1 counter registers the two read-only tim1 counter registers contain the high and low bytes of the value in the counter. reading the high byte (t1cnth) latches the contents of the low byte (t1cntl) into a buffer. subsequent reads of t1cnth do not affect the latched t1cntl value until t1cntl is read. reset clears the tim1 counter registers. setting the tim1 reset bit (trst) also clears the tim1 counter registers. note if you read t1cnth during a break interrupt, be sure to unlatch t1cntl by reading t1cntl before exiting the break interrupt. otherwise, t1cntl retains the value latched during the break. table 16-1. prescaler selection ps2 ps1 ps0 tim1 clock source 0 0 0 internal bus clock 1 0 0 1 internal bus clock 2 0 1 0 internal bus clock 4 0 1 1 internal bus clock 8 1 0 0 internal bus clock 16 1 0 1 internal bus clock 32 1 1 0 internal bus clock 64 1 1 1 t1clk (if available) bit 7654321bit 0 read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 figure 16-5. tim1 counter high register (t1cnth) bit 7654321bit 0 read: bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 write: reset: 00000000 = unimplemented figure 16-6. tim1 counter low register (t1cntl)
timer interface module (tim1) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 200 freescale semiconductor 16.8.3 tim1 counter modulo registers the read/write tim1 modulo registers contain the modulo value for the counter. when the counter reaches the modulo value, the overflow flag (tof) becomes set, and the counter resumes counting from $0000 at the next timer clock. writing to the high byte (t1modh) inhibits the tof bit and overflow interrupts until the low byte (t1modl) is written. reset sets the tim1 counter modulo registers. note reset the counter before writing to the tim1 counter modulo registers. 16.8.4 tim1 channel status and control registers each of the tim1 channel status and control registers does the following: flags input captures and output compares enables input capture and output compare interrupts selects input capture, output compare, or pwm operation selects high, low, or toggling output on output compare selects rising edge, falling edge, or any edge as the active input capture trigger selects output toggling on tim1 overflow selects 0% and 100% pwm duty cycle selects buffered or unbuffered output compare/pwm operation bit 7654321bit 0 read: bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 write: reset:11111111 figure 16-7. tim1 counter modulo high register (t1modh) bit 7654321bit 0 read: bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 write: reset:11111111 figure 16-8. tim1 counter modulo low register (t1modl)
registers mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 201 chxf ?channel x flag bit when channel x is an input capture channel, this read/write bit is set when an active edge occurs on the channel x pin. when channel x is an output compare channel, chxf is set when the value in the counter registers matches the value in the tim1 channel x registers. clear chxf by reading the t1scx register with chxf set and then writing a 0 to chxf. if another interrupt request occurs before the clearing sequence is complete, then writing 0 to chxf has no effect. therefore, an interrupt request cannot be lost due to inadvertent clearing of chxf. writing a 1 to chxf has no effect. 1 = input capture or output compare on channel x 0 = no input capture or output compare on channel x chxie ?channel x interrupt enable bit this read/write bit enables tim1 interrupt service requests on channel x. 1 = channel x interrupt requests enabled 0 = channel x interrupt requests disabled bit 7654321bit 0 read: ch0f ch0ie ms0b ms0a els0b els0a tov0 ch0max write: 0 reset:00000000 figure 16-9. tim1 channel 0 status and control register (t1sc0) bit 7654321bit 0 read: ch1f ch1ie 0 ms1a els1b els1a tov1 ch1max write: 0 reset:00000000 figure 16-10. tim1 channel 1 status and control register (t1sc1) bit 7654321bit 0 read: ch2f ch2ie ms2b ms2a els2b els2a tov2 ch2max write: 0 reset:00000000 figure 16-11. tim1 channel 2 status and control register (t1sc2) bit 7654321bit 0 read: ch3f ch3ie 0 ms3a els3b els3a tov3 ch3max write: 0 reset:00000000 = unimplemented figure 16-12. tim1 channel 3 status and control register (t1sc3)
timer interface module (tim1) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 202 freescale semiconductor msxb ?mode select bit b this read/write bit selects buffered output compare/pwm operation. msxb exists only in the t1sc0 and t1sc2 registers. setting ms0b causes the contents of t1sc1 to be ignored by the tim1 and reverts t1ch1 to general-purpose i/o. setting ms2b causes the contents of t1sc3 to be ignored by the tim1 and reverts t1ch3 to general-purpose i/o. 1 = buffered output compare/pwm operation enabled 0 = buffered output compare/pwm operation disabled msxa ?mode select bit a when elsxb:a 00, this read/write bit selects either input capture operation or unbuffered output compare/pwm operation. see table 16-2 . 1 = unbuffered output compare/pwm operation 0 = input capture operation when elsxb:a = 00, this read/write bit selects the initial output level of the t1chx pin (see table 16-2 ). 1 = initial output level low 0 = initial output level high note before changing a channel function by writing to the msxb or msxa bit, set the tstop and trst bits in the tim1 status and control register (t1sc). elsxb and elsxa ?edge/level select bits when channel x is an input capture channel, these read/write bits control the active edge-sensing logic on channel x. when channel x is an output compare channel, elsxb and elsxa control the channel x output behavior when an output compare occurs. table 16-2. mode, edge, and level selection msxb msxa elsxb elsxa mode configuration x0 0 0 output preset pin under port control; initial output level high x 1 0 0 pin under port control; initial output level low 00 0 1 input capture capture on rising edge only 0 0 1 0 capture on falling edge only 0 0 1 1 capture on rising or falling edge 01 0 0 output compare or pwm software compare only 0 1 0 1 toggle output on compare 0 1 1 0 clear output on compare 0 1 1 1 set output on compare 1x 0 1 buffered output compare or buffered pwm toggle output on compare 1 x 1 0 clear output on compare 1 x 1 1 set output on compare
registers mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 203 when elsxb and elsxa are both clear, channel x is not connected to an i/o port, and pin t1chx is available as a general-purpose i/o pin. table 16-2 shows how elsxb and elsxa work. note after initially enabling a tim1 channel register for input capture operation and selecting the edge sensitivity, clear chxf to ignore any erroneous edge detection flags. tovx ?toggle-on-over?w bit when channel x is an output compare channel, this read/write bit controls the behavior of the channel x output when the counter overflows. when channel x is an input capture channel, tovx has no effect. 1 = channel x pin toggles on counter overflow. 0 = channel x pin does not toggle on counter overflow. note when tovx is set, a counter overflow takes precedence over a channel x output compare if both occur at the same time. chxmax ?channel x maximum duty cycle bit when the tovx bit is at 1, setting the chxmax bit forces the duty cycle of buffered and unbuffered pwm signals to 100%. as figure 16-13 shows, the chxmax bit takes effect in the cycle after it is set or cleared. the output stays at the 100% duty cycle level until the cycle after chxmax is cleared. figure 16-13. chxmax latency output overflow period chxmax overflow overflow overflow overflow compare output compare output compare output compare t1chx
timer interface module (tim1) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 204 freescale semiconductor 16.8.5 tim1 channel registers these read/write registers contain the captured counter value of the input capture function or the output compare value of the output compare function. the state of the tim1 channel registers after reset is unknown. in input capture mode (msxb:msxa = 0:0), reading the high byte of the tim1 channel x registers (t1chxh) inhibits input captures until the low byte (t1chxl) is read. in output compare mode (msxb:msxa 0:0), writing to the high byte of the tim1 channel x registers (t1chxh) inhibits output compares until the low byte (t1chxl) is written. bit 7654321bit 0 read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset: indeterminate after reset figure 16-14. tim1 channel x register high (t1chxh) bit 7654321bit 0 read: bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 write: reset: indeterminate after reset figure 16-15. tim1 channel register low (t1chxl)
mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 205 chapter 17 timer interface module (tim2) 17.1 introduction this section describes the timer interface module (tim2). the tim2 module is a 2-channel timer that provides a timing reference with input capture, output compare, and pulse-width-modulation functions. the tim2 module shares its pins with general-purpose input/output (i/o) port pins. see figure 17-1 for port location of these shared pins. 17.2 features features include the following: two input capture/output compare channels rising-edge, falling-edge, or any-edge input capture trigger set, clear, or toggle output compare action buffered and unbuffered output compare pulse-width modulation (pwm) signal generation programmable clock input 7-frequency internal bus clock prescaler selection external clock input pin if available, see figure 17-1 free-running or modulo up-count operation toggle any channel pin on overflow counter stop and reset bits 17.3 functional description figure 17-2 shows the structure of the tim2. the central component of the tim2 is the 16-bit counter that can operate as a free-running counter or a modulo up-counter. the counter provides the timing reference for the input capture and output compare functions. the counter modulo registers, t2modh:t2modl, control the modulo value of the counter. software can read the counter value, t2cnth:t2cntl, at any time without affecting the counting sequence. the two tim2 channels are programmable independently as input capture or output compare channels. 17.3.1 tim2 counter prescaler the tim2 clock source is one of the seven prescaler outputs or the external clock input pin, t2clk if available. the prescaler generates seven clock rates from the internal bus clock. the prescaler select bits, ps[2:0], in the tim2 status and control register (t2sc) select the clock source.
timer interface module (tim2) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 206 freescale semiconductor figure 17-1. block diagram highlighting tim2 block and pins all port pins can be configured with internal pullup ptc not available on 16-pin devices (see note in 11.1 introduction) ptd not available on 16-pin or 20-pin devices (see note in 11.1 introduction) pta0/t1ch0/ad0/kbi0 pta1/t1ch1/ad1/kbi1 pta2/ irq/kbi2/t1clk pta3/ rst/kbi3 pta4/osc2/ad2/kbi4 pta5/osc1/ad3/kbi5 4-channel 16-bit timer module keyboard interrupt module single interrupt module periodic wakeup low-voltage inhibit cop module 10-channel 10-bit adc enhanced serial ptb0/spsck/ad4 ptb ddrb m68hc08 cpu pta ddra ptb1/mosi/t2ch1/ad5 ptb2/miso/t2ch0/ad6 ptb3/ ss/t2clk/ad7 ptb4/rxd/t2ch0/ad8 ptb5/txd/t2ch1/ad9 ptb6/t1ch2 ptb7/t1ch3 power supply v dd v ss clock generator communications interface module module serial peripheral interface 16,384 bytes mc68hc908qc16 8192 bytes mc68hc908qc8 512 bytes mc68hc908qc16 384 bytes mc68hc908qc8 break module monitor rom 2-channel 16-bit timer module ptc0 ptc1 ptc2 ptc3 ptc ddrc ptd0 ptd ddrd ptd1 ptd2 ptd3 ptd4 ptd5 ptd6 ptd7 mc68hc908qc4 user ram user flash 4096 bytes 384 bytes mc68hc908qc4
functional description mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 207 figure 17-2. tim2 block diagram 17.3.2 input capture with the input capture function, the tim2 can capture the time at which an external event occurs. when an active edge occurs on the pin of an input capture channel, the tim2 latches the contents of the counter into the tim2 channel registers, t2chxh:t2chxl. the polarity of the active edge is programmable. input captures can be enabled to generate interrupt requests. 17.3.3 output compare with the output compare function, the tim2 can generate a periodic pulse with a programmable polarity, duration, and frequency. when the counter reaches the value in the registers of an output compare channel, the tim2 can set, clear, or toggle the channel pin. output compares can be enabled to generate interrupt requests. 17.3.3.1 unbuffered output compare any output compare channel can generate unbuffered output compare pulses as described in 17.3.3 output compare . the pulses are unbuffered because changing the output compare value requires writing the new value over the old value currently in the tim2 channel registers. prescaler prescaler select 16-bit comparator ps2 ps1 ps0 16-bit comparator 16-bit latch ms0a els0b els0a tof toie 16-bit comparator 16-bit latch channel 0 channel 1 trst tstop tov0 ch0ie ch0f els1b els1a tov1 ch1ie ch1max ch1f ch0max ms0b internal bus ms1a internal bus clock interrupt logic port logic interrupt logic interrupt logic port logic (if available) 16-bit counter t2ch1 t2ch0 t2cnth:t2cntl t2modh:t2modl t2ch0h:t2ch0l t2ch1h:t2ch1l t2clk t2clk
timer interface module (tim2) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 208 freescale semiconductor an unsynchronized write to the tim2 channel registers to change an output compare value could cause incorrect operation for up to two counter overflow periods. for example, writing a new value before the counter reaches the old value but after the counter reaches the new value prevents any compare during that counter overflow period. also, using a tim2 overflow interrupt routine to write a new, smaller output compare value may cause the compare to be missed. the tim2 may pass the new value before it is written. use the following methods to synchronize unbuffered changes in the output compare value on channel x: when changing to a smaller value, enable channel x output compare interrupts and write the new value in the output compare interrupt routine. the output compare interrupt occurs at the end of the current output compare pulse. the interrupt routine has until the end of the counter overflow period to write the new value. when changing to a larger output compare value, enable tim2 overflow interrupts and write the new value in the tim2 overflow interrupt routine. the tim2 overflow interrupt occurs at the end of the current counter overflow period. writing a larger value in an output compare interrupt routine (at the end of the current pulse) could cause two output compares to occur in the same counter overflow period. 17.3.3.2 buffered output compare channels 0 and 1 can be linked to form a buffered output compare channel whose output appears on the t2ch0 pin. the tim2 channel registers of the linked pair alternately control the output. setting the ms0b bit in tim2 channel 0 status and control register (t2sc0) links channel 0 and channel 1. the output compare value in the tim2 channel 0 registers initially controls the output on the t2ch0 pin. writing to the tim2 channel 1 registers enables the tim2 channel 1 registers to synchronously control the output after the tim2 overflows. at each subsequent overflow, the tim2 channel registers (0 or 1) that control the output are the ones written to last. t2sc0 controls and monitors the buffered output compare function, and tim2 channel 1 status and control register (t2sc1) is unused. while the ms0b bit is set, the channel 1 pin, t2ch1, is available as a general-purpose i/o pin. note in buffered output compare operation, do not write new output compare values to the currently active channel registers. user software should track the currently active channel to prevent writing a new value to the active channel. writing to the active channel registers is the same as generating unbuffered output compares. 17.3.4 pulse width modulation (pwm) by using the toggle-on-overflow feature with an output compare channel, the tim2 can generate a pwm signal. the value in the tim2 counter modulo registers determines the period of the pwm signal. the channel pin toggles when the counter reaches the value in the tim2 counter modulo registers. the time between overflows is the period of the pwm signal. as figure 17-3 shows, the output compare value in the tim2 channel registers determines the pulse width of the pwm signal. the time between overflow and output compare is the pulse width. program the tim2 to clear the channel pin on output compare if the polarity of the pwm pulse is 1 (elsxa = 0). program the tim2 to set the pin if the polarity of the pwm pulse is 0 (elsxa = 1). the value in the tim2 counter modulo registers and the selected prescaler output determines the frequency of the pwm output the frequency of an 8-bit pwm signal is variable in 256 increments. writing
functional description mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 209 $00ff (255) to the tim2 counter modulo registers produces a pwm period of 256 times the internal bus clock period if the prescaler select value is 000. see 17.8.1 tim2 status and control register. the value in the tim2 channel registers determines the pulse width of the pwm output. the pulse width of an 8-bit pwm signal is variable in 256 increments. writing $0080 (128) to the tim2 channel registers produces a duty cycle of 128/256 or 50%. figure 17-3. pwm period and pulse width 17.3.4.1 unbuffered pwm signal generation any output compare channel can generate unbuffered pwm pulses as described in 17.3.4 pulse width modulation (pwm) . the pulses are unbuffered because changing the pulse width requires writing the new pulse width value over the old value currently in the tim2 channel registers. an unsynchronized write to the tim2 channel registers to change a pulse width value could cause incorrect operation for up to two pwm periods. for example, writing a new value before the counter reaches the old value but after the counter reaches the new value prevents any compare during that pwm period. also, using a tim2 overflow interrupt routine to write a new, smaller pulse width value may cause the compare to be missed. the tim2 may pass the new value before it is written to the timer channel (t2chxh:t2chxl). use the following methods to synchronize unbuffered changes in the pwm pulse width on channel x: when changing to a shorter pulse width, enable channel x output compare interrupts and write the new value in the output compare interrupt routine. the output compare interrupt occurs at the end of the current pulse. the interrupt routine has until the end of the pwm period to write the new value. when changing to a longer pulse width, enable tim2 overflow interrupts and write the new value in the tim2 overflow interrupt routine. the tim2 overflow interrupt occurs at the end of the current pwm period. writing a larger value in an output compare interrupt routine (at the end of the current pulse) could cause two output compares to occur in the same pwm period. note in pwm signal generation, do not program the pwm channel to toggle on output compare. toggling on output compare prevents reliable 0% duty cycle generation and removes the ability of the channel to self-correct in the event of software error or noise. toggling on output compare also can cause incorrect pwm signal generation when changing the pwm pulse width to a new, much larger value. period pulse width overflow overflow overflow output compare output compare output compare polarity = 1 (elsxa = 0) polarity = 0 (elsxa = 1) t2chx t2chx
timer interface module (tim2) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 210 freescale semiconductor 17.3.4.2 buffered pwm signal generation channels 0 and 1 can be linked to form a buffered pwm channel whose output appears on the t2ch0 pin. the tim2 channel registers of the linked pair alternately control the output. setting the ms0b bit in tim2 channel 0 status and control register (t2sc0) links channel 0 and channel 1. the tim2 channel 0 registers initially control the pulse width on the t2ch0 pin. writing to the tim2 channel 1 registers enables the tim2 channel 1 registers to synchronously control the pulse width at the beginning of the next pwm period. at each subsequent overflow, the tim2 channel registers (0 or 1) that control the pulse width are the ones written to last. t2sc0 controls and monitors the buffered pwm function, and tim2 channel 1 status and control register (t2sc1) is unused. while the ms0b bit is set, the channel 1 pin, t2ch1, is available as a general-purpose i/o pin. note in buffered pwm signal generation, do not write new pulse width values to the currently active channel registers. user software should track the currently active channel to prevent writing a new value to the active channel. writing to the active channel registers is the same as generating unbuffered pwm signals. 17.3.4.3 pwm initialization to ensure correct operation when generating unbuffered or buffered pwm signals, use the following initialization procedure: 1. in the tim2 status and control register (t2sc): a. stop the counter by setting the tim2 stop bit, tstop. b. reset the counter and prescaler by setting the tim2 reset bit, trst. 2. in the tim2 counter modulo registers (t2modh:t2modl), write the value for the required pwm period. 3. in the tim2 channel x registers (t2chxh:t2chxl), write the value for the required pulse width. 4. in tim2 channel x status and control register (t2scx): a. write 0:1 (for unbuffered output compare or pwm signals) or 1:0 (for buffered output compare or pwm signals) to the mode select bits, msxb:msxa. see table 17-2 . b. write 1 to the toggle-on-overflow bit, tovx. c. write 1:0 (polarity 1 ?to clear output on compare) or 1:1 (polarity 0 ?to set output on compare) to the edge/level select bits, elsxb:elsxa. the output action on compare must force the output to the complement of the pulse width level. see table 17-2 . note in pwm signal generation, do not program the pwm channel to toggle on output compare. toggling on output compare prevents reliable 0% duty cycle generation and removes the ability of the channel to self-correct in the event of software error or noise. toggling on output compare can also cause incorrect pwm signal generation when changing the pwm pulse width to a new, much larger value. 5. in the tim2 status control register (t2sc), clear the tim2 stop bit, tstop.
interrupts mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 211 setting ms0b links channels 0 and 1 and configures them for buffered pwm operation. the tim2 channel 0 registers (t2ch0h:t2ch0l) initially control the buffered pwm output. tim2 status control register 0 (t2scr0) controls and monitors the pwm signal from the linked channels. ms0b takes priority over ms0a. clearing the toggle-on-overflow bit, tovx, inhibits output toggles on tim2 overflows. subsequent output compares try to force the output to a state it is already in and have no effect. the result is a 0% duty cycle output. setting the channel x maximum duty cycle bit (chxmax) and setting the tovx bit generates a 100% duty cycle output. see 17.8.1 tim2 status and control register. 17.4 interrupts the following tim2 sources can generate interrupt requests: tim2 overflow flag (tof) ?the tof bit is set when the counter reaches the modulo value programmed in the tim2 counter modulo registers. the tim2 overflow interrupt enable bit, toie, enables tim2 overflow interrupt requests. tof and toie are in the t2sc register. tim2 channel flags (ch1f:ch0f) the chxf bit is set when an input capture or output compare occurs on channel x. channel x tim2 interrupt requests are controlled by the channel x interrupt enable bit, chxie. channel x tim2 interrupt requests are enabled when chxie =1. chxf and chxie are in the t2scx register. 17.5 low-power modes the wait and stop instructions put the mcu in low power-consumption standby modes. 17.5.1 wait mode the tim2 remains active after the execution of a wait instruction. in wait mode the tim2 registers are not accessible by the cpu. any enabled interrupt request from the tim2 can bring the mcu out of wait mode. if tim2 functions are not required during wait mode, reduce power consumption by stopping the tim2 before executing the wait instruction. 17.5.2 stop mode the tim2 module is inactive after the execution of a stop instruction. the stop instruction does not affect register conditions. tim2 operation resumes after an external interrupt. if stop mode is exited by reset, the tim2 is reset. 17.6 tim2 during break interrupts a break interrupt stops the counter and inhibits input captures. the system integration module (sim) controls whether status bits in other modules can be cleared during the break state. the bcfe bit in the break flag control register (bfcr) enables software to clear status bits during the break state. see bfcr in the sim section of this data sheet.
timer interface module (tim2) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 212 freescale semiconductor to allow software to clear status bits during a break interrupt, write a 1 to bcfe. if a status bit is cleared during the break state, it remains cleared when the mcu exits the break state. to protect status bits during the break state, write a 0 to bcfe. with bcfe cleared (its default state), software can read and write registers during the break state without affecting status bits. some status bits have a two-step read/write clearing procedure. if software does the first step on such a bit before the break, the bit cannot change during the break state as long as bcfe is cleared. after the break, doing the second step clears the status bit. 17.7 i/o signals the tim2 module can share its pins with the general-purpose i/o pins. see figure 17-1 for the port pins that are shared. 17.7.1 tim2 channel i/o pins (t2ch1:t2ch0) each channel i/o pin is programmable independently as an input capture pin or an output compare pin. t 2 ch0 can be configured as buffered output compare or buffered pwm pin. 17.7.2 tim2 clock pin (t2clk) t2clk is an external clock input that can be the clock source for the counter instead of the prescaled internal bus clock. select the t2clk input by writing 1s to the three prescaler select bits, ps[2:0]. the minimum t2clk pulse width is specified in the timer interface module characteristics table in the electricals section. the maximum t2clk frequency is the least of 4 mhz or bus frequency 2. 17.8 registers the following registers control and monitor operation of the tim2: tim2 status and control register (t2sc) tim2 control registers (t2cnth:t2cntl) tim2 counter modulo registers (t2modh:t2modl) tim2 channel status and control registers (t2sc0 and t2sc1) tim2 channel registers (t2ch0h:t2ch0l and t2ch1h:t2ch1l) 17.8.1 tim2 status and control register the tim2 status and control register (t2sc) does the following: enables tim2 overflow interrupts flags tim2 overflows stops the counter resets the counter prescales the counter clock
registers mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 213 tof ?tim2 over?w flag bit this read/write flag is set when the counter reaches the modulo value programmed in the tim2 counter modulo registers. clear tof by reading the t2sc register when tof is set and then writing a 0 to tof. if another tim2 overflow occurs before the clearing sequence is complete, then writing 0 to tof has no effect. therefore, a tof interrupt request cannot be lost due to inadvertent clearing of tof. writing a 1 to tof has no effect. 1 = counter has reached modulo value 0 = counter has not reached modulo value toie ?tim2 overflow interrupt enable bit this read/write bit enables tim2 overflow interrupts when the tof bit becomes set. 1 = tim2 overflow interrupts enabled 0 = tim2 overflow interrupts disabled tstop ?tim2 stop bit this read/write bit stops the counter. counting resumes when tstop is cleared. reset sets the tstop bit, stopping the counter until software clears the tstop bit. 1 = counter stopped 0 = counter active note do not set the tstop bit before entering wait mode if the tim2 is required to exit wait mode. also, when the tstop bit is set and the timer is configured for input capture operation, input captures are inhibited until the tstop bit is cleared. when using tstop to stop the timer counter, see if any timer flags are set. if a timer flag is set, it must be cleared by clearing tstop, then clearing the flag, then setting tstop again. trst ?tim2 reset bit setting this write-only bit resets the counter and the tim2 prescaler. setting trst has no effect on any other timer registers. counting resumes from $0000. trst is cleared automatically after the counter is reset and always reads as 0. 1 = prescaler and counter cleared 0 = no effect note setting the tstop and trst bits simultaneously stops the counter at a value of $0000. bit 7654321bit 0 read: tof toie tstop 00 ps2 ps1 ps0 write: 0 trst reset:00100000 = unimplemented figure 17-4. tim2 status and control register (t2sc)
timer interface module (tim2) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 214 freescale semiconductor ps[2:0] ?prescaler select bits these read/write bits select one of the seven prescaler outputs as the input to the counter as table 17-1 shows. 17.8.2 tim2 counter registers the two read-only tim2 counter registers contain the high and low bytes of the value in the counter. reading the high byte (t2cnth) latches the contents of the low byte (t2cntl) into a buffer. subsequent reads of t2cnth do not affect the latched t2cntl value until t2cntl is read. reset clears the tim2 counter registers. setting the tim2 reset bit (trst) also clears the tim2 counter registers. note if you read t2cnth during a break interrupt, be sure to unlatch t2cntl by reading t2cntl before exiting the break interrupt. otherwise, t2cntl retains the value latched during the break. table 17-1. prescaler selection ps2 ps1 ps0 tim2 clock source 0 0 0 internal bus clock 1 0 0 1 internal bus clock 2 0 1 0 internal bus clock 4 0 1 1 internal bus clock 8 1 0 0 internal bus clock 16 1 0 1 internal bus clock 32 1 1 0 internal bus clock 64 1 1 1 t2clk (if available) bit 7654321bit 0 read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 figure 17-5. tim2 counter high register (t2cnth) bit 7654321bit 0 read: bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 write: reset:00000000 = unimplemented figure 17-6. tim2 counter low register (t2cntl)
registers mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 215 17.8.3 tim2 counter modulo registers the read/write tim2 modulo registers contain the modulo value for the counter. when the counter reaches the modulo value, the overflow flag (tof) becomes set, and the counter resumes counting from $0000 at the next timer clock. writing to the high byte (t2modh) inhibits the tof bit and overflow interrupts until the low byte (t2modl) is written. reset sets the tim2 counter modulo registers. note reset the counter before writing to the tim2 counter modulo registers. 17.8.4 tim2 channel status and control registers each of the tim2 channel status and control registers does the following: flags input captures and output compares enables input capture and output compare interrupts selects input capture, output compare, or pwm operation selects high, low, or toggling output on output compare selects rising edge, falling edge, or any edge as the active input capture trigger selects output toggling on tim2 overflow selects 0% and 100% pwm duty cycle selects buffered or unbuffered output compare/pwm operation bit 7654321bit 0 read: bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 write: reset:11111111 figure 17-7. tim2 counter modulo high register (t2modh) bit 7654321bit 0 read: bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 write: reset:11111111 figure 17-8. tim2 counter modulo low register (t2modl) bit 7654321bit 0 read: ch0f ch0ie ms0b ms0a els0b els0a tov0 ch0max write: 0 reset:00000000 figure 17-9. tim2 channel 0 status and control register (t2sc0) bit 7654321bit 0 read: ch1f ch1ie 0 ms1a els1b els1a tov1 ch1max write: 0 reset:00000000 = unimplemented figure 17-10. tim2 channel 1 status and control register (t2sc1)
timer interface module (tim2) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 216 freescale semiconductor chxf ?channel x flag bit when channel x is an input capture channel, this read/write bit is set when an active edge occurs on the channel x pin. when channel x is an output compare channel, chxf is set when the value in the counter registers matches the value in the tim2 channel x registers. clear chxf by reading the t2scx register with chxf set and then writing a 0 to chxf. if another interrupt request occurs before the clearing sequence is complete, then writing 0 to chxf has no effect. therefore, an interrupt request cannot be lost due to inadvertent clearing of chxf. writing a 1 to chxf has no effect. 1 = input capture or output compare on channel x 0 = no input capture or output compare on channel x chxie ?channel x interrupt enable bit this read/write bit enables tim2 interrupt service requests on channel x. 1 = channel x interrupt requests enabled 0 = channel x interrupt requests disabled msxb ?mode select bit b this read/write bit selects buffered output compare/pwm operation. msxb exists only in the t2sc0. setting ms0b causes the contents of t2sc1 to be ignored by the tim2 and reverts t2ch1 to general-purpose i/o. 1 = buffered output compare/pwm operation enabled 0 = buffered output compare/pwm operation disabled msxa ?mode select bit a when elsxb:a 00, this read/write bit selects either input capture operation or unbuffered output compare/pwm operation. see table 17-2 . 1 = unbuffered output compare/pwm operation 0 = input capture operation when elsxb:a = 00, this read/write bit selects the initial output level of the t2chx pin (see table 17-2 ). 1 = initial output level low 0 = initial output level high note before changing a channel function by writing to the msxb or msxa bit, set the tstop and trst bits in the tim2 status and control register (t2sc). elsxb and elsxa ?edge/level select bits when channel x is an input capture channel, these read/write bits control the active edge-sensing logic on channel x. when channel x is an output compare channel, elsxb and elsxa control the channel x output behavior when an output compare occurs. when elsxb and elsxa are both clear, channel x is not connected to an i/o port, and pin t2chx is available as a general-purpose i/o pin. table 17-2 shows how elsxb and elsxa work.
registers mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 217 note after initially enabling a tim2 channel register for input capture operation and selecting the edge sensitivity, clear chxf to ignore any erroneous edge detection flags. tovx ?toggle-on-over?w bit when channel x is an output compare channel, this read/write bit controls the behavior of the channel x output when the counter overflows. when channel x is an input capture channel, tovx has no effect. 1 = channel x pin toggles on tim2 counter overflow. 0 = channel x pin does not toggle on tim2 counter overflow. note when tovx is set, a counter overflow takes precedence over a channel x output compare if both occur at the same time. chxmax ?channel x maximum duty cycle bit when the tovx bit is at 1, setting the chxmax bit forces the duty cycle of buffered and unbuffered pwm signals to 100%. as figure 17-11 shows, the chxmax bit takes effect in the cycle after it is set or cleared. the output stays at the 100% duty cycle level until the cycle after chxmax is cleared. figure 17-11. chxmax latency table 17-2. mode, edge, and level selection msxb msxa elsxb elsxa mode configuration x0 0 0 output preset pin under port control; initial output level high x 1 0 0 pin under port control; initial output level low 00 0 1 input capture capture on rising edge only 0 0 1 0 capture on falling edge only 0 0 1 1 capture on rising or falling edge 01 0 0 output compare or pwm software compare only 0 1 0 1 toggle output on compare 0 1 1 0 clear output on compare 0 1 1 1 set output on compare 1x 0 1 buffered output compare or buffered pwm toggle output on compare 1 x 1 0 clear output on compare 1 x 1 1 set output on compare output overflow period overflow overflow overflow overflow compare output compare output compare output compare t2chx chxmax
timer interface module (tim2) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 218 freescale semiconductor 17.8.5 tim2 channel registers these read/write registers contain the captured counter value of the input capture function or the output compare value of the output compare function. the state of the tim2 channel registers after reset is unknown. in input capture mode (msxb:msxa = 0:0), reading the high byte of the tim2 channel x registers (t2chxh) inhibits input captures until the low byte (t2chxl) is read. in output compare mode (msxb:msxa 0:0), writing to the high byte of the tim2 channel x registers (t2chxh) inhibits output compares until the low byte (t2chxl) is written. bit 7654321bit 0 read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset: indeterminate after reset figure 17-12. tim2 channel x register high (t2chxh) bit 7654321bit 0 read: bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 write: reset: indeterminate after reset figure 17-13. tim2 channel register low (t2chxl)
mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 219 chapter 18 development support 18.1 introduction this section describes the break module, the monitor module (mon), and the monitor mode entry methods. 18.2 break module (brk) the break module can generate a break interrupt that stops normal program flow at a defined address to enter a background program. features include: accessible input/output (i/o) registers during the break interrupt central processor unit (cpu) generated break interrupts software-generated break interrupts computer operating properly (cop) disabling during break interrupts 18.2.1 functional description when the internal address bus matches the value written in the break address registers, the break module issues a breakpoint signal ( bkpt) to the system integration module (sim). the sim then causes the cpu to load the instruction register with a software interrupt instruction (swi). the program counter vectors to $fffc and $fffd ($fefc and $fefd in monitor mode). the following events can cause a break interrupt to occur: a cpu generated address (the address in the program counter) matches the contents of the break address registers. software writes a 1 to the brka bit in the break status and control register. when a cpu generated address matches the contents of the break address registers, the break interrupt is generated. a return-from-interrupt instruction (rti) in the break routine ends the break interrupt and returns the microcontroller unit (mcu) to normal operation. figure 18-2 shows the structure of the break module. when the internal address bus matches the value written in the break address registers or when software writes a 1 to the brka bit in the break status and control register, the cpu starts a break interrupt by: loading the instruction register with the swi instruction loading the program counter with $fffc and $fffd ($fefc and $fefd in monitor mode)
development support mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 220 freescale semiconductor figure 18-1. block diagram highlighting brk and mon blocks all port pins can be configured with internal pullup ptc not available on 16-pin devices (see note in 11.1 introduction) ptd not available on 16-pin or 20-pin devices (see note in 11.1 introduction) pta0/t1ch0/ad0/kbi0 pta1/t1ch1/ad1/kbi1 pta2/ irq/kbi2/t1clk pta3/ rst/kbi3 pta4/osc2/ad2/kbi4 pta5/osc1/ad3/kbi5 4-channel 16-bit timer module keyboard interrupt module single interrupt module periodic wakeup low-voltage inhibit cop module 10-channel 10-bit adc enhanced serial ptb0/spsck/ad4 ptb ddrb m68hc08 cpu pta ddra ptb1/mosi/t2ch1/ad5 ptb2/miso/t2ch0/ad6 ptb3/ ss/t2clk/ad7 ptb4/rxd/t2ch0/ad8 ptb5/txd/t2ch1/ad9 ptb6/t1ch2 ptb7/t1ch3 power supply v dd v ss clock generator communications interface module module serial peripheral interface 16,384 bytes mc68hc908qc16 8192 bytes mc68hc908qc8 512 bytes mc68hc908qc16 384 bytes mc68hc908qc8 break module monitor rom 2-channel 16-bit timer module ptc0 ptc1 ptc2 ptc3 ptc ddrc ptd0 ptd ddrd ptd1 ptd2 ptd3 ptd4 ptd5 ptd6 ptd7 mc68hc908qc4 user ram user flash 4096 bytes 384 bytes mc68hc908qc4
break module (brk) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 221 figure 18-2. break module block diagram the break interrupt timing is: when a break address is placed at the address of the instruction opcode, the instruction is not executed until after completion of the break interrupt routine. when a break address is placed at an address of an instruction operand, the instruction is executed before the break interrupt. when software writes a 1 to the brka bit, the break interrupt occurs just before the next instruction is executed. by updating a break address and clearing the brka bit in a break interrupt routine, a break interrupt can be generated continuously. caution a break address should be placed at the address of the instruction opcode. when software does not change the break address and clears the brka bit in the first break interrupt routine, the next break interrupt will not be generated after exiting the interrupt routine even when the internal address bus matches the value written in the break address registers. 18.2.1.1 flag protection during break interrupts the system integration module (sim) controls whether or not module status bits can be cleared during the break state. the bcfe bit in the break flag control register (bfcr) enables software to clear status bits during the break state. see 14.8.2 break flag control register and the break interrupts subsection for each module. 18.2.1.2 tim1 during break interrupts a break interrupt stops the timer counter and inhibits input captures. 18.2.1.3 cop during break interrupts the cop is disabled during a break interrupt with monitor mode when bdcop bit is set in break auxiliary register (brkar). address bus[15:8] address bus[7:0] 8-bit comparator 8-bit comparator control break address register low break address register high address bus[15:0] bkpt (to sim)
development support mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 222 freescale semiconductor 18.2.2 break module registers these registers control and monitor operation of the break module: break status and control register (brkscr) break address register high (brkh) break address register low (brkl) break status register (bsr) break flag control register (bfcr) 18.2.2.1 break status and control register the break status and control register (brkscr) contains break module enable and status bits. brke ?break enable bit this read/write bit enables breaks on break address register matches. clear brke by writing a 0 to bit 7. reset clears the brke bit. 1 = breaks enabled on 16-bit address match 0 = breaks disabled brka ?break active bit this read/write status and control bit is set when a break address match occurs. writing a 1 to brka generates a break interrupt. clear brka by writing a 0 to it before exiting the break routine. reset clears the brka bit. 1 = break address match 0 = no break address match 18.2.2.2 break address registers the break address registers (brkh and brkl) contain the high and low bytes of the desired breakpoint address. reset clears the break address registers. bit 7654321bit 0 read: brke brka 000000 write: reset:00000000 = unimplemented figure 18-3. break status and control register (brkscr) bit 7654321bit 0 read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 figure 18-4. break address register high (brkh) bit 7654321bit 0 read: bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 write: reset:00000000 figure 18-5. break address register low (brkl)
break module (brk) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 223 18.2.2.3 break auxiliary register the break auxiliary register (brkar) contains a bit that enables software to disable the cop while the mcu is in a state of break interrupt with monitor mode. bdcop ?break disable cop bit this read/write bit disables the cop during a break interrupt. reset clears the bdcop bit. 1 = cop disabled during break interrupt 0 = cop enabled during break interrupt 18.2.2.4 break status register the break status register (bsr) contains a flag to indicate that a break caused an exit from wait mode. this register is only used in emulation mode. sbsw ?sim break stop/wait sbsw can be read within the break state swi routine. the user can modify the return address on the stack by subtracting one from it. 1 = wait mode was exited by break interrupt 0 = wait mode was not exited by break interrupt 18.2.2.5 break flag control register the break control register (bfcr) contains a bit that enables software to clear status bits while the mcu is in a break state. bit 7654321bit 0 read: 0000000 bdcop write: reset:00000000 = unimplemented figure 18-6. break auxiliary register (brkar) bit 7654321bit 0 read: rrrrrr sbsw r write: note (1) reset: 0 r = reserved 1. writing a 0 clears sbsw. figure 18-7. break status register (bsr) bit 7654321bit 0 read: bcfe rrrrrrr write: reset: 0 r = reserved figure 18-8. break flag control register (bfcr)
development support mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 224 freescale semiconductor bcfe ?break clear flag enable bit this read/write bit enables software to clear status bits by accessing status registers while the mcu is in a break state. to clear status bits during the break state, the bcfe bit must be set. 1 = status bits clearable during break 0 = status bits not clearable during break 18.2.3 low-power modes the wait and stop instructions put the mcu in low power-consumption standby modes. if enabled, the break module will remain enabled in wait and stop modes. however, since the internal address bus does not increment in these modes, a break interrupt will never be triggered. 18.3 monitor module (mon) the monitor module allows debugging and programming of the microcontroller unit (mcu) through a single-wire interface with a host computer. monitor mode entry can be achieved without use of the higher test voltage, v tst , as long as vector addresses $fffe and $ffff are blank, thus reducing the hardware requirements for in-circuit programming. features include: normal user-mode pin functionality one pin dedicated to serial communication between mcu and host computer standard non-return-to-zero (nrz) communication with host computer standard communication baud rate (7200 @ 2-mhz bus frequency) execution of code in random-access memory (ram) or flash flash memory security feature (1) flash memory programming interface use of external 9.8304 mhz oscillator to generate internal frequency of 2.4576 mhz simple internal oscillator mode of operation (no external clock or high voltage) monitor mode entry without high voltage, v tst , if reset vector is blank ($fffe and $ffff contain $ff) normal monitor mode entry if v tst is applied to irq 18.3.1 functional description figure 18-9 shows a simplified diagram of monitor mode entry. the monitor module receives and executes commands from a host computer. figure 18-10 , figure 18-11 , and figure 18-12 show example circuits used to enter monitor mode and communicate with a host computer via a standard rs-232 interface. 1. no security feature is absolutely secure. however, freescale? strategy is to make reading or copying the flash difficult for unauthorized users.
monitor module (mon) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 225 figure 18-9. simplified monitor mode entry flowchart monitor mode entry por reset pta0 = 1, pta1 = 1, and pta4 = 0? irq = v tst ? yes no yes no forced monitor mode normal user mode normal monitor mode invalid user mode no no host sends 8 security bytes is reset por? yes yes yes no are all security bytes correct? no yes enable flash disable flash execute monitor code does reset occur? conditions from table 18-1 debugging and flash programming (if flash is enabled) pta0 = 1, reset vector blank?
development support mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 226 freescale semiconductor figure 18-10. monitor mode circuit (external clock, with high voltage) figure 18-11. monitor mode circuit (external clock, no high voltage) 9.8304 mhz clock + 10 k ? * v dd 10 k? * rst (pta3) irq (pta2) pta0 osc1 (pta5) 8 7 db9 2 3 5 16 15 2 6 10 9 v dd max232 v+ v 1 f + 1 2 3 4 5 6 74hc125 74hc125 10 k ? pta1 pta4 v ss 0.1 f v dd 1k ? 9.1 v c1+ c1 5 4 1 f c2+ c2 + 3 1 1 f + 1 f v dd + 1 f v tst * value not critical v dd v dd 10 k ? * rst (pta3) irq (pta2) pta0 osc1 (pta5) 8 7 db9 2 3 5 16 15 2 6 10 9 v dd 1 f max232 v+ v v dd 1 f + 1 2 3 4 5 6 74hc125 74hc125 10 k ? n.c. pta1 n.c. pta4 v ss 0.1 f v dd 9.8304 mhz clock c1+ c1 5 4 1 f c2+ c2 + 3 1 1 f + + + 1 f v dd 10 k ? * * value not critical n.c.
monitor module (mon) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 227 figure 18-12. monitor mode circuit (internal clock, no high voltage) simple monitor commands can access any memory address. in monitor mode, the mcu can execute code downloaded into ram by a host computer while most mcu pins retain normal operating mode functions. all communication between the host computer and the mcu is through the pta0 pin. a level-shifting and multiplexing interface is required between pta0 and the host computer. pta0 is used in a wired-or configuration and requires a pullup resistor. the monitor code has been updated from previous versions of the monitor code to allow enabling the internal oscillator to generate the internal clock. this addition, which is enabled when irq is held low out of reset, is intended to support serial communication/programming at 9600 baud in monitor mode by using the internal oscillator, and the internal oscillator user trim value osctrim (flash location $ffc0, if programmed) to generate the desired internal frequency (3.2 mhz). since this feature is enabled only when irq is held low out of reset, it cannot be used when the reset vector is programmed (i.e., the value is not $ffff) because entry into monitor mode in this case requires v tst on irq. the irq pin must remain low during this monitor session in order to maintain communication. table 18-1 shows the pin conditions for entering monitor mode. as specified in the table, monitor mode may be entered after a power-on reset (por) and will allow communication at 9600 baud provided one of the following sets of conditions is met: if $fffe and $ffff do not contain $ff (programmed state): the external clock is 9.8304 mhz irq = v tst if $fffe and $ffff contain $ff (erased state): the external clock is 9.8304 mhz irq = v dd (this can be implemented through the internal irq pullup) if $fffe and $ffff contain $ff (erased state): irq = v ss (internal oscillator is selected, no external clock required) rst (pta3) irq (pta2) pta0 10 k ? * osc1 (pta5) n.c. 8 7 db9 2 3 5 16 15 2 6 10 9 v dd 1 f max232 c1+ c1 v+ v 5 4 1 f c2+ c2 v dd 1 f + 1 2 3 4 5 6 74hc125 74hc125 10 k ? n.c. pta1 n.c. pta4 v ss 0.1 f v dd + 3 1 1 f + + + 1 f v dd * value not critical n.c.
development support mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 228 freescale semiconductor the rising edge of the internal rst signal latches the monitor mode. once monitor mode is latched, the values on pta1 and pta4 pins can be changed. once out of reset, the mcu waits for the host to send eight security bytes (see 18.3.2 security ). after the security bytes, the mcu sends a break signal (10 consecutive 0s) to the host, indicating that it is ready to receive a command. 18.3.1.1 normal monitor mode rst and osc1 functions will be active on the pta3 and pta5 pins respectively as long as v tst is applied to the irq pin. if the irq pin is lowered (no longer v tst ) then the chip will still be operating in monitor mode, but the pin functions will be determined by the settings in the configuration registers (see chapter 4 configuration registers (config1 and config2) ) when v tst was lowered. with v tst lowered, the bih and bil instructions will read the irq pin state only if irqen is set in the config2 register. table 18-1. monitor mode signal requirements and options mode irq (pta2) rst (pta3) reset vector serial communi- cation mode selection cop communication speed comments pta0 pta1 pta4 external clock bus frequency baud rate normal monitor v tst v dd x 1 1 0 disabled 9.8304 mhz 2.4576 mhz 9600 provide external clock at osc1. forced monitor v dd x $ffff (blank) 1 x x disabled 9.8304 mhz 2.4576 mhz 9600 provide external clock at osc1. v ss x $ffff (blank) 1 x x disabled x 3.2 mhz (trimmed) 9600 internal clock is active. user x x not $ffff x x x enabled x x x mon08 function [pin no.] v tst [6] rst [4] com [8] mod 0 [12] mod 1 [10] osc1 [13] 1. pta0 must have a pullup resistor to v dd in monitor mode. 2. communication speed in the table is an example to obtain a baud rate of 9600. baud rate using external oscillator is bus frequency / 256 and baud rate using internal oscillator is bus frequency / 335. 3. external clock is a 9.8304 mhz oscillator on osc1. 4. x = don? care 5. mon08 pin refers to p&e microcomputer systems?mon08-cyclone 2 by 8-pin connector. nc 1 2 gnd nc 3 4 rst nc 5 6 irq nc 7 8 pta0 nc 9 10 pta4 nc 11 12 pta1 osc1 13 14 nc v dd 15 16 nc
monitor module (mon) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 229 if monitor mode was entered with v tst on irq, then the cop is disabled as long as v tst is applied to irq. 18.3.1.2 forced monitor mode if entering monitor mode without high voltage on irq, then startup port pin requirements and conditions, (pta1/pta4) are not in effect. this is to reduce circuit requirements when performing in-circuit programming. note if the reset vector is blank and monitor mode is entered, the chip will see an additional reset cycle after the initial power-on reset (por). once the reset vector has been programmed, the traditional method of applying a voltage, v tst , to irq must be used to enter monitor mode. if monitor mode was entered as a result of the reset vector being blank, the cop is always disabled regardless of the state of irq. if the voltage applied to the irq is less than v tst , the mcu will come out of reset in user mode. internal circuitry monitors the reset vector fetches and will assert an internal reset if it detects that the reset vectors are erased ($ff). when the mcu comes out of reset, it is forced into monitor mode without requiring high voltage on the irq pin. once out of reset, the monitor code is initially executing with the internal clock at its default frequency. if irq is held high, all pins will default to regular input port functions except for pta0 and pta5 which will operate as a serial communication port and osc1 input respectively (refer to figure 18-11 ). that will allow the clock to be driven from an external source through osc1 pin. if irq is held low, all pins will default to regular input port function except for pta0 which will operate as serial communication port. refer to figure 18-12. regardless of the state of the irq pin, it will not function as a port input pin in monitor mode. bit 2 of the port a data register will always read 0. the bih and bil instructions will behave as if the irq pin is enabled, regardless of the settings in the configuration register. see chapter 4 configuration registers (config1 and config2). the cop module is disabled in forced monitor mode. any reset other than a power-on reset (por) will automatically force the mcu to come back to the forced monitor mode. 18.3.1.3 monitor vectors in monitor mode, the mcu uses different vectors for reset, swi (software interrupt), and break interrupt than those for user mode. the alternate vectors are in the $fe page instead of the $ff page and allow code execution from the internal monitor firmware instead of user code. note exiting monitor mode after it has been initiated by having a blank reset vector requires a power-on reset (por). pulling rst (when rst pin available) low will not exit monitor mode in this situation. table 18-2 summarizes the differences between user mode and monitor mode regarding vectors.
development support mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 230 freescale semiconductor 18.3.1.4 data format communication with the monitor rom is in standard non-return-to-zero (nrz) mark/space data format. transmit and receive baud rates must be identical. figure 18-13. monitor data format 18.3.1.5 break signal a start bit (logic 0) followed by nine logic 0 bits is a break signal. when the monitor receives a break signal, it drives the pta0 pin high for the duration of two bits and then echoes back the break signal. figure 18-14. break transaction 18.3.1.6 baud rate the monitor communication baud rate is controlled by the frequency of the external or internal oscillator and the state of the appropriate pins as shown in table 18-1 . table 18-1 also lists the bus frequencies to achieve standard baud rates. the effective baud rate is the bus frequency divided by 256 when using an external oscillator. when using the internal oscillator in forced monitor mode, the effective baud rate is the bus frequency divided by 335. 18.3.1.7 commands the monitor rom firmware uses these commands: read (read memory) write (write memory) iread (indexed read) iwrite (indexed write) readsp (read stack pointer) run (run user program) table 18-2. mode difference modes functions reset vector high reset vector low break vector high break vector low swi vector high swi vector low user $fffe $ffff $fffc $fffd $fffc $fffd monitor $fefe $feff $fefc $fefd $fefc $fefd bit 5 start bit bit 1 next stop bit start bit bit 2 bit 3 bit 4 bit 7 bit 0 bit 6 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 missing stop bit 2-stop bit delay before zero echo
monitor module (mon) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 231 the monitor rom firmware echoes each received byte back to the pta0 pin for error checking. an 11-bit delay at the end of each command allows the host to send a break character to cancel the command. a delay of two bit times occurs before each echo and before read, iread, or readsp data is returned. the data returned by a read command appears after the echo of the last byte of the command. note wait one bit time after each echo before sending the next byte. figure 18-15. read transaction figure 18-16. write transaction a brief description of each monitor mode command is given in table 18-3 through table 18-8 . table 18-3. read (read memory) command description read byte from memory operand 2-byte address in high-byte:low-byte order data returned returns contents of speci?d address opcode $4a command sequence read read echo from host address high address high address low address low data return 1 3, 2 11 4 4 notes: 2 = data return delay, approximately 2 bit times 3 = cancel command delay, 11 bit times 4 = wait 1 bit time before sending next byte. 44 1 = echo delay, approximately 2 bit times write write echo from host address high address high address low address low data data notes: 2 = cancel command delay, 11 bit times 3 = wait 1 bit time before sending next byte. 11 3 11 3 3 3 2, 3 1 = echo delay, approximately 2 bit times read read echo sent to monitor address high address high address low data return address low
development support mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 232 freescale semiconductor a sequence of iread or iwrite commands can access a block of memory sequentially over the full 64-kbyte memory map. table 18-4. write (write memory) command description write byte to memory operand 2-byte address in high-byte:low-byte order; low byte followed by data byte data returned none opcode $49 command sequence table 18-5. iread (indexed read) command description read next 2 bytes in memory from last address accessed operand none data returned returns contents of next two addresses opcode $1a command sequence table 18-6. iwrite (indexed write) command description write to last address accessed + 1 operand single data byte data returned none opcode $19 command sequence write write echo from host address high address high address low address low data data iread iread echo data return data from host iwrite iwrite echo from host data data
monitor module (mon) mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 233 the mcu executes the swi and pshh instructions when it enters monitor mode. the run command tells the mcu to execute the pulh and rti instructions. before sending the run command, the host can modify the stacked cpu registers to prepare to run the host program. the readsp command returns the incremented stack pointer value, sp + 1. the high and low bytes of the program counter are at addresses sp + 5 and sp + 6. figure 18-17. stack pointer at monitor mode entry table 18-7. readsp (read stack pointer) command description reads stack pointer operand none data returned returns incremented stack pointer value (sp + 1) in high-byte:low-byte order opcode $0c command sequence table 18-8. run (run user program) command description executes pulh and rti instructions operand none data returned none opcode $28 command sequence readsp readsp echo from host sp return sp high low run run echo from host condition code register accumulator low byte of index register high byte of program counter low byte of program counter sp + 1 sp + 2 sp + 3 sp + 4 sp + 5 sp sp + 6 high byte of index register sp + 7
development support mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 234 freescale semiconductor 18.3.2 security a security feature discourages unauthorized reading of flash locations while in monitor mode. the host can bypass the security feature at monitor mode entry by sending eight security bytes that match the bytes at locations $fff6?fffd. locations $fff6?fffd contain user-defined data. note do not leave locations $fff6?fffd blank. for security reasons, program locations $fff6?fffd even if they are not used for vectors. during monitor mode entry, the mcu waits after the power-on reset for the host to send the eight security bytes on pin pta0. if the received bytes match those at locations $fff6?fffd, the host bypasses the security feature and can read all flash locations and execute code from flash. security remains bypassed until a power-on reset occurs. if the reset was not a power-on reset, security remains bypassed and security code entry is not required. see figure 18-18 . upon power-on reset, if the received bytes of the security code do not match the data at locations $fff6?fffd, the host fails to bypass the security feature. the mcu remains in monitor mode, but reading a flash location returns an invalid value and trying to execute code from flash causes an illegal address reset. after receiving the eight security bytes from the host, the mcu transmits a break character, signifying that it is ready to receive a command. note the mcu does not transmit a break character until after the host sends the eight security bytes. to determine whether the security code entered is correct, check to see if bit 6 of ram address $80 is set. if it is, then the correct security code has been entered and flash can be accessed. if the security sequence fails, the device should be reset by a power-on reset and brought up in monitor mode to attempt another entry. after failing the security sequence, the flash module can also be mass erased by executing an erase routine that was downloaded into internal ram. the mass erase operation clears the security code locations so that all eight security bytes become $ff (blank). figure 18-18. monitor mode entry timing byte 1 byte 1 echo byte 2 byte 2 echo byte 8 byte 8 echo command command echo pa0 rst v dd 4096 + 32 busclkx4 cycles 1 3 1 1 2 1 break notes: 2 = data return delay, approximately 2 bit times 3 = wait 1 bit time before sending next byte 3 from host from mcu 1 = echo delay, approximately 2 bit times 4 4 = wait until clock is stable and monitor runs
mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 235 chapter 19 electrical specifications 19.1 introduction this section contains electrical and timing specifications. 19.2 absolute maximum ratings maximum ratings are the extreme limits to which the microcontroller unit (mcu) can be exposed without permanently damaging it. note this device is not guaranteed to operate properly at the maximum ratings. refer to 19.5 5-v dc electrical characteristics and 19.8 3.3-v dc electrical characteristics for guaranteed operating conditions. note this device contains circuitry to protect the inputs against damage due to high static voltages or electric fields; however, it is advised that normal precautions be taken to avoid application of any voltage higher than maximum-rated voltages to this high-impedance circuit. for proper operation, it is recommended that v in and v out be constrained to the range v ss (v in or v out ) v dd . reliability of operation is enhanced if unused inputs are connected to an appropriate logic voltage level (for example, either v ss or v dd .) characteristic (1) 1. voltages references to v ss . symbol value unit supply voltage v dd 0.3 to +6.0 v input voltage v in v ss 0.3 to v dd +0.3 v mode entry voltage, irq pin v tst v ss 0.3 to +9.1 v maximum current per pin excluding pta0?ta5, v dd , and v ss i 15 ma maximum current for pins pta0?ta5 i pta0 i pta5 25 ma storage temperature t stg 55 to +150 c maximum current out of v ss i mvss 100 ma maximum current into v dd i mvdd 100 ma
electrical specifications mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 236 freescale semiconductor 19.3 functional operating range 19.4 thermal characteristics this section provides information about operating temperature range, power dissipation, and package thermal resistance. power dissipation on i/o pins is usually small compared to the power dissipation in on-chip logic and voltage regulator circuits, and it is user-determined rather than being controlled by the mcu design. to take p i/o into account in power calculations, determine the difference between actual pin voltage and v ss or v dd and multiply by the pin current for each i/o pin. except in cases of unusually high pin current (heavy loads), the difference between pin voltage and v ss or v dd will be very small. characteristic symbol value unit temp. code operating temperature range t a 40 to +125 40 to +105 40 to +85 c m v c operating voltage range v dd 3.0 to 5.5 v maximum junction temperature t max 135 c table 19-1. thermal characteristics rating symbol value unit thermal resistance single-layer board (1 signal plane) 28-pin soic ja 68 c/w 28-pin tssop 94 20-pin soic 75 20-pin tssop 109 16-pin soic 84 16-pin tssop 123 thermal resistance four-layer board (2 signal planes, 2 power planes) 28-pin soic ja 45 c/w 28-pin tssop 61 20-pin soic 46 20-pin tssop 68 16-pin soic 50 16-pin tssop 77
5-v dc electrical characteristics mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 237 the average chip-junction temperature (t j ) in c can be obtained from: t j = t a + (p d ja ) eqn. 19-1 where: t a = ambient temperature, c ja = package thermal resistance, junction-to-ambient, c/w p d = p int + p i/o p int = i dd v dd , watts ?chip internal power p i/o = power dissipation on input and output pins ?user determined for most applications, p i/o << p int and can be neglected. an approximate relationship between p d and t j (if p i/o is neglected) is: p d = k (t j + 273c) eqn. 19-2 solving equation 19-1 and equation 19-2 for k gives: k = p d (t a + 273c) + ja (p d ) 2 eqn. 19-3 where k is a constant pertaining to the particular part. k can be determined from equation 3 by measuring p d (at equilibrium) for a known t a . using this value of k, the values of p d and t j can be obtained by solving equation 19-1 and equation 19-2 iteratively for any value of t a . 19.5 5-v dc electrical characteristics characteristic (1) symbol min typ (2) max unit output high voltage i load = ?.0 ma, all i/o pins i load = ?0.0 ma, all i/o pins i load = ?5.0 ma, pta0, pta1, pta3?ta5 only v oh v dd 0.4 v dd 1.5 v dd 0.8 v maximum combined i oh (all i/o pins) i oht 50 ma output low voltage i load = 1.6 ma, all i/o pins i load = 10.0 ma, all i/o pins i load = 15.0 ma, pta0, pta1, pta3?ta5 only v ol 0.4 1.5 0.8 v maximum combined i ol (all i/o pins) i ohl 50 ma input high voltage pta0?ta5, ptb0?tb7, ptc3?tc0, ptd7?td0 v ih 0.7 x v dd ? dd v input low voltage pta0?ta5, ptb0?tb7, ptc3?tc0, ptd7?td0 v il v ss 0.3 x v dd v input hysteresis v hys 0.06 x v dd v ?continued on next page
electrical specifications mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 238 freescale semiconductor dc injection current (3) (4) (5) (6) single pin limit v in > v dd v in < v ss total mcu limit, includes sum of all stressed pins v in > v dd v in < v ss i ic 0 0 0 0 2 ?.2 25 ? ma ports hi-z leakage current i il 0 1 a capacitance ports (as input) (3) c in 8p f por rearm voltage v por 750 mv por rise time ramp rate (3)(7) r por 0.035 v/ms monitor mode entry voltage (3) v tst v dd + 2.5 9.1 v pullup resistors (8) pta0?ta5, ptb0?tb7, ptc3?tc0, ptd7?td0 r pu 16 26 36 k ? pulldown resistors (6) pta0?ta5 r pd 16 26 36 k ? low-voltage inhibit reset, trip falling voltage (9) v tripf 3.90 4.20 4.50 v low-voltage inhibit reset, trip rising voltage v tripr 4.00 4.30 4.60 v low-voltage inhibit reset/recover hysteresis v hys 100 mv 1. v dd = 4.5 to 5.5 vdc, v ss = 0 vdc, t a = t l to t h , unless otherwise noted. 2. typical values reflect average measurements at midpoint of voltage range, 25 conly. typical values are for reference only and are not tested in production. 3. values are based on characterization results, not tested in production. 4. all functional non-supply pins are internally clamped to v ss and v dd . 5. input must be current limited to the value specified. to determine the value of the required current-limiting resistor, calculate resistance values for positive and negative clamp voltages, then use the larger of the two values. 6. power supply must maintain regulation within operating v dd range during instantaneous and operating maximum current conditions. if positive injection current (v in > v dd ) is greater than i dd , the injection current may flow out of v dd and could result in external power supply going out of regulation. ensure external v dd load will shunt current greater than maximum injection current. this will be the greatest risk when the mcu is not consuming power. examples are: if no system clock is present, or if clock rate is very low (which would reduce overall power consumption). 7. if minimum v dd is not reached before the internal por reset is released, the lvi will hold the part in reset until minimum v dd is reached. 8. r pu and r pd, is measured at v dd = 5.0 v. pulldown resistors only available when kbix is enabled with kbixpol =1. 9. functionality of mcu guaranteed by production test down to minimum lvi trip point. the electrical parameters are only guaranteed within the specified operating voltage range. characteristic (1) symbol min typ (2) max unit
typical 5-v output drive characteristics mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 239 19.6 typical 5-v output drive characteristics figure 19-1. typical 5-volt output high voltage versus output high current (25c) figure 19-2. typical 5-volt output low voltage versus output low current (25c) 0.0 0.2 0.4 0.6 0.8 1.0 1.2 1.4 1.6 -30 -25 -20 -15 -10 -5 0 ioh (ma) vdd-voh (v) 5v pta 5v ptb,ptc,ptd 0.0 0.2 0.4 0.6 0.8 1.0 1.2 1.4 1.6 0 5 10 15 20 25 30 iol (ma) vol (v) 5v pta 5v ptb,ptc,ptd
electrical specifications mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 240 freescale semiconductor 19.7 5-v control timing figure 19-3. rst and irq timing 19.8 3.3-v dc electrical characteristics characteristic (1) 1. v dd = 4.5 to 5.5 vdc, v ss = 0 vdc, t a = t l to t h ; timing shown with respect to 20% v dd and 70% v ss , unless otherwise noted. symbol min max unit internal operating frequency f op (f bus ) 8 mhz internal clock period (1/f op ) t cyc 125 ns rst input pulse width low (2) 2. values are based on characterization results, not tested in production. t rl 100 ns irq interrupt pulse width low (edge-triggered) (2) t ilih 100 ns irq interrupt pulse period (2) t ilil note (3) 3. the minimum period is the number of cycles it takes to execute the interrupt service routine plus 1 t cyc . ? cyc characteristic (1) symbol min typ (2) max unit output high voltage i load = ?.6 ma, all i/o pins i load = ?.0 ma, all i/o pins i load = ?0.0 ma, pta0, pta1, pta3?ta5 only v oh v dd 0.3 v dd 1.0 v dd 0.8 v maximum combined i oh (all i/o pins) i oht 50 ma output low voltage i load = 0.5 ma, all i/o pins i load = 6.0 ma, all i/o pins i load = 10.0 ma, pta0, pta1, pta3?ta5 only v ol 0.3 1.0 0.8 v maximum combined i ol (all i/o pins) i ohl 50 ma input high voltage pta0?ta5, ptb0?tb7, ptc3?tc0, ptd7?td0 v ih 0.7 x v dd ? dd v input low voltage pta0?ta5, ptb0?tb7, ptc3?tc0, ptd7?td0 v il v ss 0.3 x v dd v ?continued on next page rst irq t rl t ilih t ilil
3.3-v dc electrical characteristics mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 241 input hysteresis v hys 0.06 x v dd v dc injection current (3) (4) (5) (6) single pin limit v in > v dd v in < v ss total mcu limit, includes sum of all stressed pins v in > v dd v in < v ss i ic 0 0 0 0 2 ?.2 25 ? ma ports hi-z leakage current i il 0 1 a capacitance ports (as input) (3) c in 8p f por rearm voltage v por 750 mv por rise time ramp rate (3)(7) r por 0.035 v/ms monitor mode entry voltage (3) v tst v dd + 2.5 v dd + 4.0 v pullup resistors (8) pta0?ta5, ptb0?tb7, ptc3?tc0, ptd7?td0 r pu 16 26 36 k ? pulldown resistors (6) pta0?ta5 r pd 16 26 36 k ? low-voltage inhibit reset, trip falling voltage (9) v tripf 2.65 2.85 3.0 v low-voltage inhibit reset, trip rising voltage v tripr 2.73 2.93 3.08 v low-voltage inhibit reset/recover hysteresis v hys ?0mv 1. v dd = 3.0 to 3.6 vdc, v ss = 0 vdc, t a = t l to t h , unless otherwise noted. 2. typical values reflect average measurements at midpoint of voltage range, 25 c only. 3. values are based on characterization results, not tested in production. 4. all functional non-supply pins are internally clamped to v ss and v dd . 5. input must be current limited to the value specified. to determine the value of the required current-limiting resistor, calculate resistance values for positive and negative clamp voltages, then use the larger of the two values. 6. power supply must maintain regulation within operating v dd range during instantaneous and operating maximum current conditions. if positive injection current (v in > v dd ) is greater than i dd , the injection current may flow out of v dd and could result in external power supply going out of regulation. ensure external v dd load will shunt current greater than maximum injection current. this will be the greatest risk when the mcu is not consuming power. examples are: if no system clock is present, or if clock rate is very low (which would reduce overall power consumption). 7. if minimum v dd is not reached before the internal por reset is released, the lvi will hold the part in reset until minimum v dd is reached. 8. r pu and r pd measured at v dd = 3.3 v. pulldown resistors only available when kbix is enabled with kbixpol =1. 9. functionality of mcu guaranteed by production test down to minimum lvi trip point. the electrical parameters are only guaranteed within the specified operating voltage range. characteristic (1) symbol min typ (2) max unit
electrical specifications mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 242 freescale semiconductor 19.9 typical 3.3-v output drive characteristics figure 19-4. typical 3.3-volt output high voltage versus output high current (25 c) figure 19-5. typical 3.3-volt output low voltage versus output low current (25 c) 0.0 0.2 0.4 0.6 0.8 1.0 1.2 -25 -20 -15 -10 -5 0 ioh (ma) vdd-voh (v) 3.3v pta 3.3v ptb,ptc,ptd 0.0 0.2 0.4 0.6 0.8 1.0 1.2 0 5 10 15 20 25 iol (ma) vol (v) 3.3v pta 3.3v ptb,ptc,ptd
3.3-v control timing mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 243 19.10 3.3-v control timing figure 19-6. rst and irq timing 19.11 oscillator characteristics characteristic (1) 1. v dd = 3.0 to 3.6 vdc, v ss = 0 vdc, t a = t l to t h ; timing shown with respect to 20% v dd and 70% v dd , unless otherwise noted. symbol min max unit internal operating frequency f op (f bus ) 4 mhz internal clock period (1/f op ) t cyc 250 ns rst input pulse width low (2) 2. values are based on characterization results, not tested in production. t rl 200 ns irq interrupt pulse width low (edge-triggered) (2) t ilih 200 ns irq interrupt pulse period (2) t ilil note (3) 3. the minimum period is the number of cycles it takes to execute the interrupt service routine plus 1 t cyc . ? cyc characteristic symbol min typ max unit internal oscillator frequency (1) icfs1:icfs0 = 00 icfs1:icfs0 = 01 icfs1:icfs0 = 10 icfs1:icfs0 = 11 (not allowed if v dd < 4.5 v) f intclk 4 8 12.8 25.6 mhz trim accuracy (2)(3) ? trim_acc 0.4 % deviation from trimmed internal oscillator (3)(4) 4, 8, 12.8, 25.6mhz, v dd 10%, 0 to 70c 4, 8, 12.8, 25.6mhz, v dd 10%, ?0 to 125c ? int_trim 2 5 % external rc oscillator frequency, rcclk (1) (3) v dd 4.5 v v dd < 4.5 v f rcclk 2 2 12 8.4 mhz external clock reference frequency (1) (5) (6) v dd 4.5 v v dd 3.0 v f oscxclk dc dc 32 16 mhz ?continued on next page rst irq t rl t ilih t ilil
electrical specifications mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 244 freescale semiconductor rc oscillator external resistor v dd = 5 v v dd = 3.3 v r ext see figure 19-7 see figure 19-8 crystal frequency, xtalclk (1) (7) (8) ecfs1:ecfs0 = 00 (v dd 4.5 v) ecfs1:ecfs0 = 00 ecfs1:ecfs0 = 01 ecfs1:ecfs0 = 10 f oscxclk 8 8 1 30 32 16 8 100 mhz mhz mhz khz ecfs1:ecfs0 = 00 (9) (f oscxclk : 8?2 mhz) feedback bias resistor crystal load capacitance (10) crystal capacitors (10) r b c l c 1 , c 2 1 20 (2 x c l ) ?5pf m? pf pf ecfs1:ecfs0 = 01 (9) (f oscxclk : 1? mhz) crystal series damping resistor f oscxclk = 1 mhz f oscxclk = 4 mhz f oxcsclk = 8 mhz feedback bias resistor crystal load capacitance (10) crystal capacitors (10) r s r b c l c 1 , c 2 20 10 0 5 18 (2 x c l ) ?0pf k? k? k? m? pf pf ecfs1:ecfs0 = 10 (9) (f oscxclk : 30?00 khz) feedback bias resistor crystal load capacitance (10) crystal capacitors (10) r b c l c 1 , c 2 10 12.5 (2 x c l ) ?0 m? pf pf pwu module internal rc oscillator frequency f intrc 32 khz 1. bus frequency, f op , is oscillator frequency divided by 4. 2. factory trimmed to provided 12.8mhz accuracy requirement ( 5%, @ 25 c and v dd = 5.0 v) for forced monitor mode communication. user should trim in-circuit to obtain the most accurate internal oscillator frequency for his application. 3. values are based on characterization results, not tested in production. 4. deviation values assumes trimming in target application @25 c and midpoint of voltage range, for example 5.0 v for 5 v 10% operation. 5. no more than 10% duty cycle deviation from 50%. 6. when external oscillator clock is greater than 1 mhz, ecfs1:ecfs0 must be 00 or 01. 7. use fundamental mode only, do not use overtone crystals or overtone ceramic resonators. 8. due to variations in electrical properties of external components such as, esr and load capacitance, operation above 16 mhz is not guaranteed for all crystals or ceramic resonators. operation above 16 mhz requires that a negative resistance margin (nrm) characterization and component optimization be performed by the crystal or ceramic resonator vendor for every different type of crystal or ceramic resonator which will be used. this characterization and optimization must be performed at the extremes of voltage and temperature which will be applied to the microcontroller in the application. the nrm must meet or exceed 10x the maximum esr of the crystal or ceramic resonator for acceptable performance. 9. do not use damping resistor when ecfs1:ecfs0 = 00 or 10. 10. consult crystal vendor data sheet. characteristic symbol min typ max unit
oscillator characteristics mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 245 figure 19-7. rc versus frequency (5 volts @ 25 c) figure 19-8. rc versus frequency (3.3 volts @ 25 c) 0 2 4 6 8 10 12 14 0 1 02 03 04 05 06 0 r ext (k ) rc frequency, f rcclk (mhz ) 5 v 25 c 3.3v 25 o c 0 2 4 6 8 10 12 0 102030405060 r ext (k ohms) rc frequency, f rcclk (mhz)
electrical specifications mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 246 freescale semiconductor 19.12 supply current characteristics characteristic (1) 1. v ss = 0 vdc, t a = t l to t h , unless otherwise noted. voltage bus frequency (mhz) symbol typ (2) 2. typical values reflect average measurement at 25c only. typical values are for reference only and are not tested in production. max unit run mode v dd supply current (3) 3. run (operating) i dd measured using trimmed internal oscillator, adc off, all modules enabled. all pins configured as inputs and tied to 0.2 v from rail. 5.0 3.3 3.2 3.2 ri dd 5.0 2.6 8.5 4.5 ma wait mode v dd supply current (4) 4. wait i dd measured using trimmed internal oscillator, adc off, all modules enabled. all pins configured as inputs and tied to 0.2 v from rail. 5.0 3.3 3.2 3.2 wi dd 1.8 1.2 3.3 2.2 ma stop mode v dd supply current (5) ?0 to 85c ?0 to 105c ?0 to 125c 25 c with pwu enabled incremental current with lvi enabled at 25 c 5. stop i dd measured with all pins configured as inputs and tied to 0.2 v from rail. on the 8-pin versions, port b is configured as inputs with pullups enabled. 5.0 si dd 0.40 12 125 1.5 2.0 6.5 a stop mode v dd supply current (5) ?0 to 85c ?0 to 105c ?0 to 125c 25 c with pwu enabled incremental current with lvi enabled at 25 c 3.3 0.23 2 100 1.5 2.0 5.0 a
supply current characteristics mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 247 figure 19-9. typical 5-volt run current versus bus frequency (25 c) figure 19-10. typical 3.3-volt run current versus bus frequency (25 c) 12 10 8 6 4 2 0 01234567 bus frequency (mhz) i dd (ma) internal oscillator no a/d serial internal oscillator a/d serial crystal no a/d serial crystal a/d serial internal oscillator no a/d serial internal oscillator a/d serial crystal no a/d serial crystal a/d serial i dd (ma) bus frequency (mhz) 5 4 3 2 1 0 0 1234
electrical specifications mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 248 freescale semiconductor 19.13 adc10 characteristics characteristic conditions symbol min typ (1) max unit comment supply voltage absolute v dd 3.0 5.5 v supply current adlpc = 1 adlsmp = 1 adco = 1 v dd < 3.6 v (3.3 v typ) i dd (2) ?5 a v dd < 5.5 v (5.0 v typ) ?5 supply current adlpc = 1 adlsmp = 0 adco = 1 v dd < 3.6 v (3.3 v typ) i dd (2) 120 a v dd < 5.5 v (5.0 v typ) 175 supply current adlpc = 0 adlsmp = 1 adco = 1 v dd < 3.6 v (3.3 v typ) i dd (2) 140 a v dd < 5.5 v (5.0 v typ) 180 supply current adlpc = 0 adlsmp = 0 adco = 1 v dd < 3.6 v (3.3 v typ) i dd (2) 340 a v dd < 5.5 v (5.0 v typ) 440 615 adc internal clock high speed (adlpc = 0) f adck 0.40 (3) 2.00 mhz t adck = 1/f adck low power (adlpc = 1) 0.40 (3) 1.00 conversion time (4) 10-bit mode short sample (adlsmp = 0) t adc 19 19 21 t adck cycles long sample (adlsmp = 1) 39 39 41 conversion time (4) 8-bit mode short sample (adlsmp = 0) t adc 16 16 18 t adck cycles long sample (adlsmp = 1) 36 36 38 sample time short sample (adlsmp = 0) t ads 444 t adck cycles long sample (adlsmp = 1) 24 24 24 input voltage v adin v ss ? dd v input capacitance c adin 7 10 pf not tested input impedance r adin 5 15 k ? not tested analog source impedance r as 10 k ? external to mcu ideal resolution (1 lsb) 10-bit mode res 1.758 5 5.371 mv v refh /2 n 8-bit mode 7.031 20 21.48 total unadjusted error 10-bit mode e tue 0 1.5 2.5 lsb includes quantization 8-bit mode 0 0.7 1.0 ?continued on next page
adc10 characteristics mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 249 differential non-linearity 10-bit mode dnl 0 0.5 lsb 8-bit mode 0 0.3 monotonicity and no-missing-codes guaranteed integral non-linearity 10-bit mode inl 0 0.5 lsb 8-bit mode 0 0.3 zero-scale error 10-bit mode e zs 0 0.5 lsb v adin = v ss 8-bit mode 0 0.3 full-scale error 10-bit mode e fs 0 0.5 lsb v adin = v dd 8-bit mode 0 0.3 quantization error 10-bit mode e q 0.5 lsb 8-bit mode is not truncated 8-bit mode 0.5 input leakage error 10-bit mode e il 0 0.2 5 lsb pad leakage (5) * r as 8-bit mode 0 0.1 1.2 bandgap voltage input (3(6) v bg 1.17 1.245 1.32 v 1. typical values assume v dd = 5.0 v, temperature = 25 c, f adck = 1.0 mhz unless otherwise stated. typical values are for reference only and are not tested in production. 2. incremental i dd added to mcu mode current. 3. values are based on characterization results, not tested in production. 4. reference the adc module specification for more information on calculating conversion times. 5. based on typical input pad leakage current. 6. lvi must be enabled, (lvipwrd = 0, in config1). voltage input to adch4:0 = $1a, an adc conversion on this channel allows user to determine supply voltage. characteristic conditions symbol min typ (1) max unit comment
electrical specifications mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 250 freescale semiconductor 19.14 5.0-volt spi characteristics diagram number (1) 1. numbers refer to dimensions in figure 19-11 and figure 19-12. characteristic (2) 2. all timing is shown with respect to 20% v dd and 70% v dd , unless noted; 100 pf load on all spi pins. symbol min max unit operating frequency master slave f op(m) f op(s) f op /128 dc f op /2 f op mhz mhz 1 cycle time master slave t cyc(m) t cyc(s) 2 1 128 t cyc t cyc 2 enable lead time t lead(s) 1t cyc 3 enable lag time t lag(s) 1t cyc 4 clock (spsck) high time master slave t sckh(m) t sckh(s) t cyc ?5 1/2 t cyc ?5 64 t cyc ns ns 5 clock (spsck) low time master slave t sckl(m) t sckl(s) t cyc ?5 1/2 t cyc ?5 64 t cyc ns ns 6 data setup time (inputs) master slave t su(m) t su(s) 30 30 ns ns 7 data hold time (inputs) master slave t h(m) t h(s) 30 30 ns ns 8 access time, slave (3) cpha = 0 cpha = 1 3. time to data active from high-impedance state t a(cp0) t a(cp1) 0 0 40 40 ns ns 9 disable time, slave (4) 4. hold time to high-impedance state t dis(s) ? 0n s 10 data valid time, after enable edge master slave (5) 5. with 100 pf on all spi pins t v(m) t v(s) 50 50 ns ns 11 data hold time, outputs, after enable edge master slave t ho(m) t ho(s) 0 0 ns ns
3.3-volt spi characteristics mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 251 19.15 3.3-volt spi characteristics diagram number (1) 1. numbers refer to dimensions in figure 19-11 and figure 19-12. characteristic (2) 2. all timing is shown with respect to 20% v dd and 70% v dd , unless noted; 100 pf load on all spi pins. symbol min max unit operating frequency master slave f op(m) f op(s) f op /128 dc f op /2 f op mhz mhz 1 cycle time master slave t cyc(m) t cyc(s) 2 1 128 t cyc t cyc 2 enable lead time t lead(s) 1t cyc 3 enable lag time t lag(s) 1t cyc 4 clock (spsck) high time master slave t sckh(m) t sckh(s) t cyc ?5 1/2 t cyc ?5 64 t cyc ns ns 5 clock (spsck) low time master slave t sckl(m) t sckl(s) t cyc ?5 1/2 t cyc ?5 64 t cyc ns ns 6 data setup time (inputs) master slave t su(m) t su(s) 40 40 ns ns 7 data hold time (inputs) master slave t h(m) t h(s) 40 40 ns ns 8 access time, slave (3) cpha = 0 cpha = 1 3. time to data active from high-impedance state t a(cp0) t a(cp1) 0 0 50 50 ns ns 9 disable time, slave (4) 4. hold time to high-impedance state t dis(s) ? 0n s 10 data valid time, after enable edge master slave (5) 5. with 100 pf on all spi pins t v(m) t v(s) 60 60 ns ns 11 data hold time, outputs, after enable edge master slave t ho(m) t ho(s) 0 0 ns ns
electrical specifications mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 252 freescale semiconductor figure 19-11. spi master timing note note: this first clock edge is generated internally, but is not seen at the spsck pin. ss pin of master held high msb in ss input spsck output spsck output miso input mosi output note 4 5 5 1 4 bits 6? lsb in master msb out bits 6? master lsb out 11 10 11 7 6 note note: this last clock edge is generated internally, but is not seen at the spsck pin. ss pin of master held high msb in ss input spsck output spsck output miso input mosi output note 4 5 5 1 4 bits 6? lsb in master msb out bits 6? master lsb out 10 11 10 7 6 a) spi master timing (cpha = 0) b) spi master timing (cpha = 1) cpol = 0 cpol = 1 cpol = 0 cpol = 1
3.3-volt spi characteristics mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 253 figure 19-12. spi slave timing note: not defined but normally msb of character just received slave ss input spsck input spsck input miso input mosi output 4 5 5 1 4 msb in bits 6? 8 6 10 5 11 note slave lsb out 9 3 lsb in 2 7 bits 6? msb out note: not defined but normally lsb of character previously transmitted slave ss input spsck input spsck input miso output mosi input 4 5 5 1 4 msb in bits 6? 8 6 10 note slave lsb out 9 3 lsb in 2 7 bits 6? msb out 10 a) spi slave timing (cpha = 0) b) spi slave timing (cpha = 1) 11 11 cpol = 0 cpol = 1 cpol = 0 cpol = 1
electrical specifications mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 254 freescale semiconductor 19.16 timer interface module characteristics figure 19-13. timer input timing characteristic symbol min max unit timer input capture pulse width (1) 1. values are based on characterization results, not tested in production. t th, t tl 2t cyc timer input capture period t tltl note (2) 2. the minimum period is the number of cycles it takes to execute the interrupt service routine plus 1 t cyc . ? cyc timer input clock pulse width (1) t tcl , t tch t cyc + 5 ns input capture rising edge input capture falling edge input capture both edges t th t tl t tltl t tltl t tltl t tl t th tclk t tcl t tch
memory characteristics mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 255 19.17 memory characteristics characteristic symbol min typ (1) 1. typical values are for reference only and are not tested in production. max unit ram data retention voltage (2) 2. values are based on characterization results, not tested in production. v rdr 1.3 v flash program bus clock frequency 1 mhz flash pgm/erase supply voltage (v dd ) v pgm/erase 2.7 5.5 v flash read bus clock frequency f read (3) 3. f read is defined as the frequency range for which the flash memory can be read. 08 mhz flash page erase time t erase 3.6 4 5.5 ms flash mass erase time t merase 4ms flash pgm/erase to hven setup time t nvs 10 s flash high-voltage hold time t nvh 5 s flash high-voltage hold time (mass erase) t nvhl 100 s flash program hold time t pgs 5 s flash program time t prog 30 40 s flash return to read time t rcv (4) 4. t rcv is defined as the time it needs before the flash can be read after turning off the high voltage charge pump, by clearing hven to 0. 1 s flash cumulative program hv period t hv (5) 5. t hv is defined as the cumulative high voltage programming time to the same row before next erase. t hv must satisfy this condition: t nvs + t nvh + t pgs + (t prog x 32) t hv maximum. 4ms flash endurance (6) 6. typical endurance was evaluated for this product family. for additional information on how freescale defines typical endurance, please refer to engineering bulletin eb619. 10 k 100 k cycles flash data retention time (7) 7. typical data retention values are based on intrinsic capability of the technology measured at high temperature and de-rated to 25 c using the arrhenius equation. for additional information on how freescale defines typical data retention , please refer to engineering bulletin eb618. 15 100 years
electrical specifications mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 256 freescale semiconductor
mc68hc908qc16 ?mc68hc908qc8 ?mc68hc908qc4 data sheet, rev. 5 freescale semiconductor 257 chapter 20 ordering information and mechanical specifications 20.1 introduction this section contains order numbers for the mc68hc908qc16, mc68hc908qc8, and mc68hc908qc4. see table 20-1 and figure 20-1 . 20.2 mc order numbers figure 20-1. device numbering system 20.3 package dimensions refer to the following pages for detailed package dimensions. table 20-1. mc order numbers temp. range 16 tssop 16 soic 20 tssop 20 soic 28 tssop 28 soic automotive c = ?0 c to 85 c s908qc16cdte(r) s908qc16cdse s908qc16cdre s908qc8cdte s908qc8cdse s908qc8cdre v = ?0 c to 105c s908qc16vdse s908qc8vdse m = ?0c to 125 c s908qc16mdte s908qc16mdse(r) s908qc16mdre s908qc8mdte s908qc8mdse(r) s908qc8 mdre s908qc4mdse(r) s908ac4mdre consumer and industrial c = ?0 c to 85 c mc908qc16cdte mc908qc16cdxe mc908qc16cdse mc908qc16cdye mc908qc16cdre mc908qc16cdze mc908qc8cdte mc908qc8cdxe mc908qc8cdse mc908qc8cdye mc908qc8cdre mc908qc8cdze mc908qc4cdre v = ?0 c to 105c mc908qc16vdse mc908qc16vdre mc908qc8vdse mc908qc8vdre temperature designators: c = 40 c to +85 c v = 40 c to +105 c m = 40 c to +125 c package designators: dx = 16-pin soic dy = 20-pin soic dz = 28-pin soic dt = 16-pin tssop ds = 20-pin tssop dr = 28-pin tssop x 908 qcx x xx e r device grade: s = auto mc = consumer family temperature range tape and reel pb free package designator
















how to reach us: home page: www.freescale.com e-mail: support@freescale.com usa/europe or locations not listed: freescale semiconductor technical information center, ch370 1300 n. alma school road chandler, arizona 85224 +1-800-521-6274 or +1-480-768-2130 support@freescale.com europe, middle east, and africa: freescale halbleiter deutschland gmbh technical information center schatzbogen 7 81829 muenchen, germany +44 1296 380 456 (english) +46 8 52200080 (english) +49 89 92103 559 (german) +33 1 69 35 48 48 (french) support@freescale.com japan: freescale semiconductor japan ltd. headquarters arco tower 15f 1-8-1, shimo-meguro, meguro-ku, tokyo 153-0064 japan 0120 191014 or +81 3 5437 9125 support.japan@freescale.com asia/paci?: freescale semiconductor hong kong ltd. technical information center 2 dai king street tai po industrial estate tai po, n.t., hong kong +800 2666 8080 support.asia@freescale.com for literature requests only: freescale semiconductor literature distribution center p.o. box 5405 denver, colorado 80217 1-800-441-2447 or 303-675-2140 fax: 303-675-2150 ldcforfreescalesemiconductor@hibbertgroup.com rohs-compliant and/or pb-free versions of freescale products have the functionality and electrical characteristics of their non-rohs-compliant and/or non-pb-free counterparts. for further information, see http://www.freescale.com or contact your freescale sales representative. for information on freescales environmental products program, go to http://www.freescale.com/epp . information in this document is provided solely to enable system and software implementers to use freescale semiconductor products. there are no express or implied copyright licenses granted hereunder to design or fabricate any integrated circuits or integrated circuits based on the information in this document. freescale semiconductor reserves the right to make changes without further notice to any products herein. freescale semiconductor makes no warranty, representation or guarantee regarding the suitability of its products for any particular purpose, nor does freescale semiconductor assume any liability arising out of the application or use of any product or circuit, and speci?ally disclaims any and all liability, including without limitation consequential or incidental damages. ?ypical?parameters that may be provided in freescale semiconductor data sheets and/or speci?ations can and do vary in different applications and actual performance may vary over time. all operating parameters, including ?ypicals? must be validated for each customer application by customers technical experts. freescale semiconductor does not convey any license under its patent rights nor the rights of others. freescale semiconductor products are not designed, intended, or authorized for use as components in systems intended for surgical implant into the body, or other applications intended to support or sustain life, or for any other application in which the failure of the freescale semiconductor product could create a situation where personal injury or death may occur. should buyer purchase or use freescale semiconductor products for any such unintended or unauthorized application, buyer shall indemnify and hold freescale semiconductor and its of?ers, employees, subsidiaries, af?iates, and distributors harmless against all claims, costs, damages, and expenses, and reasonable attorney fees arising out of, directly or indirectly, any claim of personal injury or death associated with such unintended or unauthorized use, even if such claim alleges that freescale semiconductor was negligent regarding the design or manufacture of the part. freescale and the freescale logo are trademarks of freescale semiconductor, inc. all other product or service names are the property of their respective owners. ?freescale semiconductor, inc. 20 08 . all rights reserved. mc68hc908qc16 rev.5, 4/2008


▲Up To Search▲   

 
Price & Availability of MC68HC908QC1612

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X